We study the long-term effects of intergroup contact on nation building by exploiting a national lottery that randomly allocated conscripts to different military areas across Spain. For men born in regions that feature a weak Spanish identity, we find that being assigned to military service in a different region substantially increases self-identification as Spanish, increases the likelihood of voting in national elections and reduces the probability of voting for a regionalist party. Moreover, in support of intergroup contact as the main mechanism behind these results, we find that movers are more likely than nonmovers to have friends from other regions.