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. We further contrast the electoral impacts of trade exposure with shocks associated with generalized changes in labor demand and with the post-2006 U.S. housing market collapse.