We use a difference-in-differences framework to study the effects of affirmative action policies in the setting of imperial China. Imperial China used an examination system to select government officials. A reform was launched in 1712 to lower inequality in access to exams and government jobs. By equalizing acceptance rates across the provinces and allowing individuals from underrepresented provinces to pass the exam with lower scores, the reform led to an increase in the number of successful candidates in underrepresented provinces and an improvement in their academic and career outcomes. However, we find that such gains were concentrated among individuals in prefectures with the greatest advantage in imperial exams before the reform, resulting in growing inequality within the provinces. These divergent trends between prefectures persisted decades into the reform but were mitigated in prefectures where candidates received travel subsidies.