Religious groups sometimes resist welfare-enhancing interventions, impacting human capital. Can resistance to secular education arise when rulers sharing religious identity with a group are deposed by foreign powers? Focusing on colonial India, we analyze the impact of shared religious identity between deposed local rulers and religious groups on literacy. Muslim literacy is lower where British authorities replaced a Muslim ruler, and Hindu literacy is lower when the ousted ruler was Hindu. Addressing OVB, we use literacy differences, complemented by an IV approach. Our results show that the effect of shared religious identity on literacy rates depended on the historical ties between deposed rulers and their subjects: in districts where ousted rulers had historical connections to their co-religionists, there was greater resistance to education introduced by the colonizers.