Has rising import competition 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 congressional voting records, we find strong evidence that congressional districts exposed to larger increases in import penetration disproportionately removed moderate representatives from office in the 2000s. Trade-exposed districts with an initial majority white population or initially in Republican hands became substantially more likely to elect a conservative Republican, while trade-exposed districts with an initial majority- minority population or initially in Democratic hands also become more likely to elect a liberal Democrat. We interpret these results as supporting a political economy literature that connects adverse economic conditions to support for nativist politicians. We also contrast the electoral impacts of trade exposure with shocks associated with generalized changes in labor demand and the post-2006 U.S. housing market collapse.