We experimentally analyze the effect of the endogenous choice of sanctioning institutions on cooperation and migration patterns across societies. In our experiment, subjects are allocated to one of two groups, are endowed with group-specific preferences, and play a public goods game for 30 periods. Each period, subjects can move between groups and, at fixed intervals, can vote on whether to implement formal (centralized) sanctioning institutions in their group. We compare this environment to one in which only one group is exogenously endowed with sanctioning institutions. We find that subjects' ability to vote on institutions leads to (i) a more efficient partition of subjects between groups, (ii) a lower migration rate, (iii) an increase in overall payoffs, and (iv) a decrease in both inter- and intra-groups (payoff) inequality. Over time, subjects tend to vote for sanctioning institutions and contribute to the public good.