In human societies, cooperative behavior in joint enterprises is often enforced through institutions that impose sanctions on defectors. Many experiments on so-called public goods games have shown that in the absence of such institutions, individuals are willing to punish defectors, even at a cost to themselves. Theoretical models confirm that social norms prescribing the punishment of uncooperative behavior are stable—once established, they prevent dissident minorities from spreading. But how can such costly punishing behavior gain a foothold in the population? A surprisingly simple model shows that if individuals have the option to stand aside and abstain from the joint endeavor, this paves the way for the emergence and establishment of cooperative behavior based on the punishment of defectors. Paradoxically, the freedom to withdraw from the common enterprise leads to enforcement of social norms. Joint enterprises that are compulsory rather than voluntary are less likely to lead to cooperation.