We examine how overall delivery of public goods (i.e., efficiency) is affected by affirmative action in elections, i.e., restricting candidate entry in elections to one population group. We argue that when group identities are salient, such restrictions on candidate entry need not necessarily reduce electoral competition. In fact, when group sizes are asymmetric, affirmative action may increase electoral competition and consequently, improve provision of public goods. This happens because in an open election, the (best) candidate from the large group facing a minority candidate suffers from a moral hazard problem. Affirmative action eliminates this problem and increases within-group competition. We study a randomized caste based quota policy in village elections in a large state in India to test these claims. Consistently, we find that electoral quotas for a caste group (OBCs) increased provision of public goods in villages with high OBC population shares. We show that this did not happen due to changes in politicians preferences or quality, and the increased provision of public goods did not disproportionately benefit the OBCs. Further, using election data, we show evidence in favor of our mechanism: win margins are narrower in quota elections relative to open elections in villages where OBC group is large. Our results highlight that efficiency concerns regarding affirmative action in politics may need reevaluation.