We use a population resettlement program in Indonesia to identify long-run effects of intergroup contact on national integration. In the 1980s, the government relocated two million ethnically diverse migrants into hundreds of new communities. We find greater integration in fractionalized communities with many small groups, as measured by national language use at home, intermarriage, and children’s name choices. However, in polarized communities with a few large groups, ethnic attachment increases and integration declines. Residential segregation dampens these effects. Social capital, public goods, and ethnic conflict follow similar patterns. Overall, our findings highlight the importance of localized contact in shaping identity.