We study whether legal restrictions on prenatal discrimination against females leads to a shift by parents towards postnatal discrimination, focusing on the impact on educational attainment. We exploit the differentially timed in troduction of a ban on sex-selective abortions across states in India to find that a legal restriction on abortions led to an increase in the number of females born, as well as a widening in the gender gap in educational attainment. Females born in states affected by the ban are 2.3, 3.5 and 3.2 percentage points less likely to complete Grade 10, complete Grade 12 and enter university relative to males. These effects are concentrated among non-wealthy households that lacked the resources to evade the ban. Investigating mechanisms, we find that the relative reduction in investments in female education were not driven by family size but because surviving females were now relatively unwanted, whereas surviving males are relatively more valued, leading to an increasing concentration of household resources on them. Discrimination is amplied among higher order births and among females with relatively few sisters. Finally, these negative effects exist despite the existence of a marriage market channel through which parents increase investments in their daughters’ education to increase the probability that they make a high-quality match. This suggests that policymakers need to address the unintended welfare consequences of interventions aimed at promoting gender equity.