Most of the debate about the North American Free Trade Agreement has focused on job losses. It is certainly true that over the last 25 years many manufacturing jobs in the United States have disappeared. A conservative estimate suggests that half of those jobs have been automated in one way or another, or companies have found ways to be more productive with fewer workers, but some studies find that 85% of the job losses can be attributed to technological change. The other half may have been lost due to offshoring and other types of investments made by US and US-based companies; some fraction has also been lost to foreign competition due to cheaper imports. But has NAFTA contributed significantly to that process? Yes, in fact it is reasonable to conclude that around 800,000 jobs may have moved south of the border to Mexico, a country with lower base wages and less stringent business regulations.

NAFTA, however, has also created jobs in the United States—anywhere between two and four million jobs depend on trade with Mexico. Indeed, what most politicians, analysts, and commentators forget is that the NAFTA has created tens of thousands of jobs in the US at the expense of countries like Germany, Japan, and South Korea that used to ship their goods to us but now make them here. While this much-maligned trade agreement provides free trade among its three signatories, it is actually a protectionist trade pact relative to the rest of the world.

Take the example of automobiles: Before NAFTA came into effect at the beginning of 1994, exports of automobiles from the above mentioned countries were literally flooding the US market. But NAFTA made it more expensive for European and East Asian automobile companies to export because the North American local content requirement was raised from 50% to 62.5%.

This meant that in order to avoid tariffs, a vehicle sold in the US (or Canada or Mexico for that matter) had to incorporate more value in its components originating from within the NAFTA zone. At the same time, the rules under NAFTA as to how that local content requirement is calculated became more stringent.

The companies’ response to NAFTA’s protectionist stance was swift. Within months, the Japanese, South Korean, and German automobile firms were making plans to shift production away from their respective home countries and establish assembly facilities in the United States. Toyota established new manufacturing capacity in Indiana (starting production in 1990), BMW in South Carolina (1994), Mercedes-Benz in Alabama (1997), Honda in Alabama (2001), Hyundai in Alabama (2005), KIA in Georgia (2008), and Volkswagen in Tennessee (2011).

Each of these assembly plants required the co-location of hundreds of suppliers. If there are about 800,000 US workers engaged in automobile assembly and component manufacturing, a bit more than a third work for foreign-owned companies. Many of those jobs would, without NAFTA, be located in Europe or East Asia.

The political aspects of this protectionism should also not be overlooked. President Trump campaigned on a platform that leaned heavily on the narrative of Midwestern unemployment. This is only part of the story, however. Investments by European and East Asian firms have benefited workers and their communities in the US—but not necessarily in the Rust Belt. Instead, they preferred regions with weaker unions and more favorable tax treatment, available in states like Alabama, Georgia, South Carolina or Tennessee.

In addition, the original intention behind the protectionist treatment of foreign-made automobiles was to help the Big Three—GM, Ford, and Chrysler. Yet NAFTA has largely failed to benefit these US companies, which increasingly found it difficult to compete. In some cases it actually had the opposite effect, shifting small-car production offshore (including to Mexico), and focusing on trucks, minivans, and SUVs, for which they had, at least temporarily, a competitive advantage.

This process, of both creating new jobs and destroying others, is called “creative destruction,” and it is a key aspect of our market economy. The same process has taken place in many other manufacturing industries, from aerospace to furniture, electronics, and toys.

Unlike some of the talk coming out of the Trump administration, however, the solution is not to fall back on protectionism. In fact, such policies will ultimately hurt consumers, make companies lazy, reduce the incentives for innovation, and encourage interest groups who benefit from the protections to lobby so that they are never removed. The solution must instead be to take care of those who are negatively affected and help them adapt to the changing economy.

We are not going to get US manufacturing jobs back, but that doesn’t mean we won’t be able to create more jobs in other sectors. In the United States, we have failed to take care of our own workers, not only in response to free trade but also as a result of technological disruption. Ultimately, free trade is not the bad guy here, even if it is a politically expedient bogeyman.