A Mexican worker in a California vineyard, near the town of Lamont.
Photograph: David Levene for the Guardian

Bullies have a habit of blaming their victims. So the American alt-right has blamed poor Mexicans for stealing US jobs with their cheap labour and illegal immigration, and Donald Trump won votes by promising to rip up Nafta – the North American Free Trade Agreement – which has been so damaging to hard-working families. As with so much about this post-fact era, there is some truth in the argument. The problem is that it has been turned on its head.

Nafta was introduced in 1994 and was the first trade agreement to merge the markets of two rich economies – the US and Canada – with a poor one: Mexico. By 2004 it had become clear that it was a disaster for many poor Mexicans and was driving them to emigrate. The country saw an overall decline in employment in both agriculture and manufacturing and a rapid increase in inequality. This is where you have to look if you really want to understand the drivers behind the spike in illegal immigration to the US over that decade.

There was growth initially in “assembly” manufacturing in Mexico – the sector that has been blamed so much for undermining US factories – in which foreign companies were allowed to import materials duty- and tariff-free for processing in factories near the border with the US, before re-exporting them back to their originating country.

It made, and still makes, substantial profits for US corporations using the cheap labour, as the free trade agreement intended, but wages for those employed to do the work were insufficient to support a family. By 2001 Mexico was losing manufacturing jobs to China, with its even lower wages. It could only benefit if its own people’s wages remained impossibly low.

When Nafta was signed, around 18 million Mexicans depended on corn production for their livelihoods. Tortillas, made from corn flour, are the country’s staple food. In the two years after Nafta, imports of corn from the US doubled. The US continued to support its agribusiness heavily, with corn production alone accounting for about $10bn a year in government payouts and subsidies.

Free trade as negotiated by powerful developed countries has a habit of being lopsided like this, and not quite as free as it claims. So US exporters, dominated by a handful of giant grain traders, were able to sell corn on the newly liberalised Mexican market at artificially low prices, decimating three million local producers. In theory the fall in prices should at least have helped the mass of urban poor; but it didn’t. In fact tortilla prices went up sevenfold – as part of the agreed liberalisation the Mexican government was required to remove some of its supports that kept tortilla prices cheap in government stores.

The biggest beneficiaries of the fall in corn prices were the two large processors that dominated the Mexican market. American transnationals and local Mexican elites got richer. The poor got poorer. If the new trade had generated much greater tax revenues for the Mexican government, or indeed for the US government, they might have been able to mitigate the effects, but transnationals park their profits offshore in tax-haven subsidiaries.

An estimated 1.3 million Mexicans were driven off the land by Nafta. The flow of illegal workers to the US increased dramatically. It is a bit rich, in other words, to attack Mexico and Nafta for one of the effects it was predicted it would have on poor Mexicans and migration.

This being the real world of complex social and economic interactions rather than Trumpland, the story has another side. The Mexican government was supposed to prepare for the shock of liberalisation on smallholders over a 10-year period, but failed. Mexico’s debt crisis and the devaluation of the peso played their part.

Large-scale migration from Mexico to the US of course began before Nafta. Some US sectors, such as agriculture, depend on it. Most US retailers, for instance, source significant volumes of fruit and vegetables from California. The state has used undocumented workers from Mexico for decades. There was a spike in numbers in the 2000s post-Nafta, however, so that by the end of that decade, 70% of California’s agricultural workforce was foreign-born, most being from Mexico and half of them having arrived illegally.

They work for poverty wages in conditions local Americans will not tolerate. If Trump’s famous wall and deportations come to pass, US farm companies will struggle to harvest their produce. Brexit Britain’s East Anglian farmers, dependent on EU migrants, fear a similar labour crisis.

1.3 million Mexicans were driven off the land by Nafta. The flow of illegal workers to the US increased dramatically

Nafta has brought some gains: Mexican mega-farms that live on exports have done well; cities in central Mexico with new manufacturing have seen an emerging new prosperous middle class. The flow of migration to the US slowed dramatically after the 2008 financial crisis. But as a development model it has failed. The poor remain poor. And, yes, ordinary American workers have lost out too.

But if there is to be a settling of bills, Mexicans would have cause to throw one the way of the US. For post-Nafta, its transnationals flooded Mexico with their calorie-dense, nutrition-light, processed foods and drinks, exporting their obesity epidemic too. Rates of diabetes associated with it have soared, just as the free trade agreement restricted the introduction of generic drugs and extended the patents of pharmaceutical companies, straining the health budget.

Similar free trade agreements have been pursued aggressively by the US and the EU in the last two decades as an alternative to the endlessly stalled World Trade Organisation talks. They give greatly increased intellectual property rights and patents to corporates, so that they may collect what amounts to a private tax on transactions. The balance of power in negotiations is always with the richer countries and with transnational corporations and elites.

People are angry, but they have been steered to the wrong target. Trump is right that the rules of trade need to be rewritten. They need to be recast not to give more power and money to tax-dodging big business, but to share profits more equitably to those pushed to the bottom of the pile, on either side of the border. Sadly nothing Trump has said in his rabid attacks on Mexican migrants suggests that, as he heads for the White House, he has any intention of doing that.