Has rising trade integration between the U.S. and China contributed to the polarization of U.S. politics? Analyzing outcomes from the 2002 and 2010 congressional elections, we detect an ideological realignment that is centered in trade-exposed local labor markets and that commences prior to the divisive 2016 U.S. presidential election. Exploiting the exogenous component of rising trade with China and classifying legislator ideologies by their congressional voting record, we find strong evidence that congressional districts exposed to larger increases in import competition disproportionately removed moderate representatives from office in the 2000s. Trade-exposed districts initially in Republican hands become substantially more likely to elect a conservative Republican, while trade-exposed districts initially in Democratic hands become more likely to elect either a liberal Democrat or a conservative Republican. Polarization is also evident when breaking down districts by race: trade-exposed locations with a majority white population are disproportionately likely to replace moderate legislators with conservative Republicans, whereas locations with a majority non-white population tend to replace moderates with liberal Democrats. In contrast with much previous work in political science, we find limited impacts of economic shocks on the probability of party turnover (an anti-incumbency effect) or on the electoral vote shares of the major parties (a party realignment effect). Focusing on legislator behavior rather than on party vote counts, we find that trade exposure abets the replacement of incumbents from both parties with more ideologically strident successors.