President Trump continues threatening to withdraw the United States from the North American Free Trade Agreement, and with negotiations on rocky ground, that risk could soon become reality. Withdrawing from the pact would bring big changes for the economy and for consumers.

Since the pact came into effect in 1994, United States trade with Mexico and Canada has more than tripled, growing more rapidly than American trade with the rest of the world. Mexico and Canada are now the second and third largest exporters to the United States, after China. And the two countries are the leading importers of American products.

Mr. Trump has criticized Nafta for creating an unfair playing field, allowing Mexico to steal jobs from the United States and opening the border to cheap, tariff-free goods. He wants to bring factory jobs back home.

But pulling out of the pact could have unintended economic consequences. Over the past quarter century, Nafta has reshaped the United States economy, and its demise could raise costs for American companies and consumers.