Abstract We explore how institutional designs can have unintended consequences, especially by rewiring social networks. Using archival data on the civil-service examinations in historical China, we argue that the enforcement of a regional quota system in 1427 reshaped group boundaries along native place, turned emotional affinities for one’s hometown into political stakes, and reinforced the influence of native place ties among political elites. Analyzing approximately 30,000 individual records, we confirm this argument by documenting a macro-level shift from a highly unequal to a more balanced provincial distribution of students who passed the examinations following the enforcement of the quota system. As native place became a primary basis for network homophily, elites deliberately cultivated these connections, seizing the opportunity as ad hoc examiners to provide preferential treatment based on shared place of origin. Our micro-level analysis of 12,752 passing students between 1400 and 1580 identifies this in-group favoritism, with examiners often ranking students from their own provinces higher. A mechanism of safeguarding political stakes underscores this baseline effect, which became more pronounced during the quota stage, especially under weaker state capacity, among examiners from disadvantaged provinces, and when examiners had greater vested interest in their hometown. These findings enrich theories of group boundaries and categorization, network homophily and formation, and the unintended consequences of institutional designs while also providing policy insights for affirmative action.