This paper investigates the determinants of political polarization, a phenomenon of increasing relevance in Western democracies. How much of polarization is driven by divergence in the ideologies of politicians? How much is instead the result of changes in the capacity of parties to control their members? We use detailed internal information on party discipline in the context of the U.S. Congress – whip count data for 1977-1986 – to identify and structurally estimate an economic model of legislative activity in which agenda selection, party discipline, and member votes are endogenous. The model delivers estimates of the ideological preferences of politicians, the extent of party control, and allows us to assess the effects of polarization through agenda setting (i.e. which alternatives to a status quo are strategically pursued). We find that parties account for approximately 40 percent of the political polarization in legislative voting over this time period, a critical inflection point in U.S. polarization. We also show that, absent party control, historically significant economic policies would have not passed or lost substantial support. Counterfactual exercises establish that party control is highly relevant for the probability of success of a given bill and that polarization in ideological preferences is more consequential for policy selection, resulting in different bills being pursued.