Due to incomplete contracts, efficiency of an organization depends on willingness of individuals to take non-selfish actions, such as cooperating when there is no incentive to do so or punishing inefficient actions by others. Organizations also constitute a social boundary, or group. We investigate whether this social aspect of organizations has an important benefit- fostering unselfish cooperation and norm enforcement within the group-but also whether there is a dark side, in the form of hostility between groups. Our experiment provides the first evidence free from the confounding effect of self-selection into groups. Individuals are randomly assigned to different platoons during a four-week period of officer training in the Swiss Army. We conduct choice experiments-simultaneous prisoner's dilemma games, with and without third-party punishment-in week three. Random assignment significantly increases willingness to cooperate with fellow platoon members. Assignment does not lead to hostility, in the sense of vindictive punishment of outsiders, but does affect norm enforcement, enhancing willingness to enforce a norm of cooperation towards fellow platoon members. This suggests that the social aspect of organizations motivates efficient behavior even when ordinary incentives fail and helps to explain practices designed to foster social ties or group identification within an organization.