SO COMMON is anti-trade rhetoric in the election campaign that you might think America is about to erect a wall on every side. Donald Trump threatens to slap a 45% tariff on Chinese imports and to bully firms into returning their factories to America. Bernie Sanders proudly recalls his unwavering opposition to free-trade agreements, past and current. And Hillary Clinton, having supported the Trans-Pacific Partnership (TPP), the latest trade accord, as secretary of state, now opposes it.

Presidential candidates have taken such positions in the past. Barack Obama, who today peddles trade deals, slammed them in 2008. What makes today’s protectionism more potent is that it draws on broader changes in thinking among economists about the impact of trade. Many are now a good deal more critical.

Since the 1980s, America’s economy has gradually opened up to cheap imports. This accelerated in 1993, when President Bill Clinton signed the North American Free-Trade Agreement (NAFTA) with Mexico and Canada. The deal, America’s first broad trade accord to include a poor economy, eliminated most tariffs on trade between the three countries over a decade. Coincidentally, within a year of the start of tariff reductions, the peso collapsed, making Mexican imports cheaper still. Excluding fuel (which America had to buy from somewhere) imports from Mexico grew by about five times between 1993 and 2013, according to the Peterson Institute, a think-tank. Exports to Mexico grew by about three-and-a-half times. As a result of the disparity, a bilateral trade deficit worth $23 billion (then, 0.2% of America’s GDP) opened up within five years.

The small size of Mexico’s economy—America’s is still well over ten times bigger—limited NAFTA’s impact. A greater shock was coming: in 2001 China joined the World Trade Organisation (WTO). Although this did not change any tariffs, a tsunami of cheap Chinese imports followed. “Made in China” labels became ubiquitous on clothes, toys, furniture and, eventually, electronics as Chinese imports surged from 1% of GDP in 2000 to 2.7% by 2015. The best explanation for this sudden inflow is that WTO membership gave certainty to investors in China’s export industries; until then, America could impose higher tariffs on China at will.

Many blamed the yuan’s peg to the dollar for creating a trade imbalance. By 2014 China had accumulated nearly $4 trillion in foreign currency to sustain the peg. Economists have always struggled to formalise the allegation that China manipulates the yuan. Over time, higher wage inflation in booming China should undermine the advantage of a weak currency. Wages have indeed risen much faster in China than in the West. China’s current-account surplus, which reached 10% of GDP in 2007, is often cited as proof of fiddling. But Chinese surpluses and American deficits are—as a matter of accounting—the difference between saving and investment in those countries. So China’s vast surpluses in part reflected its extraordinary propensity to save.

In any case, cheap imports were a windfall for American consumers. Excluding food and energy, prices of goods have fallen almost every year since NAFTA. Clothes now cost the same as they did in 1986; furnishing a house is as cheap as it was 35 years ago. More trade brought more choice, too. Robert Lawrence and Lawrence Edwards, two economists, estimate that trade with China alone put $250 a year into the pocket of every American by 2008. The gains from cheap stuff flowed disproportionately to the less well-off, because the poor spend more of their incomes on goods than the rich.

At the same time, trade created new markets for American firms. In 1993 America sold nearly $10 billion-worth of cars and parts to Mexico, at today’s prices. By 2013 that had risen to $70 billion. Many American firms have become tightly integrated across the southern border, with low-skilled work done in Mexico and more complex tasks done at home. Exports to China grew by almost 200% between 2005 and 2014, with agriculture and the aerospace and car industries leading the charge. Some workers have benefited from rising exports, because firms that export pay more; one estimate puts the export wage-premium at 18%. Outsourcing low-wage assembly has also increased the productivity of America’s high-skilled workers. For example, Apple’s ability to assemble its iPhones cheaply in China has made the work of its American designers much more lucrative.

The gain and the pain

Trade, though, has an acute image problem. Its benefits are hard to perceive directly, spread as they are across large constituencies: consumers, exporters, and workers who may not realise just how much of what they make is shipped overseas. In contrast, its costs are highly concentrated. Cheap imports have been lethal for many American manufacturers, particularly in the midwestern rustbelt and in the South.

Economic theory predicts that trade, though often good for average incomes, will squeeze the pay of those workers whose skills are relatively abundant overseas. A sharp rise in the college premium—the additional wages earned by skilled workers—from around 30% in 1979 to almost 50% by 2000 seemed to corroborate that theory, as it coincided with the first wave of cheap imports (see chart). But for some time there was scant evidence of a causal link between the two trends. In 1995 Paul Krugman, a trade economist, estimated that trade with poor countries explained only a tenth of the growth in the skilled-worker premium in the 1980s. Mr Krugman and others found that technological change was more to blame. That would explain why the return to education increased even in poor countries, which trade theory did not predict. But by 2008 Mr Krugman had changed his mind, warning that the sheer volume of trade with China and other poor countries was probably increasing inequality. In 2013 an updated estimate of his model showed that trade with poor countries depressed unskilled workers’ wages by 10% in 2011, up from 2.7% in 1979, according to Josh Bivens of the Economic Policy Institute, a think-tank. In that time, trade accounted for one-third of the rise in the college premium. For other economists, the impact of trade on jobs was a growing concern. The sharp decline in American manufacturing employment began in 2000, just as Chinese imports took off (see chart). Yet on the extreme assumption that every dollar spent on imports replaced a dollar spent employing an American, Mr Lawrence calculates that between 2000 and 2007 Chinese imports caused, at most, 188,000 of 484,000 annual manufacturing-job losses. A recent, more detailed, estimate by Daron Acemoglu, David Autor and others chalks up about 1m of 5.5m manufacturing jobs lost between 1999 and 2011 to Chinese competition (with similar-sized job losses in other industries).

This implies that many other factors are in play. Technological change is probably the prime culprit for shrinking manufacturing employment. Productivity increases in the industry have been staggering. For instance, since 1994 carmaking’s contribution to GDP—to which outsourced production by American firms does not contribute—has fallen by about 10%. But there are 30% fewer carmaking jobs. This had led to the false impression that America’s car industry has outsourced most of its work. Such are the advances in manufacturing technology that if China disappeared tomorrow, far fewer jobs would return to America’s shores than left them.

But another recent achievement of trade economists has been to show that trade-induced job losses, while relatively small, are particularly painful: more so than those caused by technology. Until recently, most economists assumed that displaced workers could find new work relatively easily. After all, in June 2007, on the eve of the financial crisis, unemployment was 4.6%—lower than it was before the recession of the early 1990s. Between 2000 and 2007 Americans left 5m jobs a month and started 5.1m new ones. A million or so jobs lost to trade with China over more than a decade seems tiny by comparison.

But many workers displaced by Chinese imports did not simply find another job. Mr Autor and his colleagues have shown that, at local level, employment falls at least one-for-one with jobs lost to trade, and that displaced workers are unlikely to move to seek new work. The lowest-skilled who do find new jobs tend to move to similar, and thus similarly vulnerable, employment. One reason for this immobility could be that the economy is now an unwelcoming place for jobseekers without a university degree. The housing collapse of the late 2000s, which left many Americans trapped in negative equity, may have made things worse. This new strain of research has lent support to the claim of Dani Rodrik, a globalisation sceptic, that “If you are of low skill, have little education, and are not very mobile, international trade has been bad news for you pretty much throughout your entire life.”

The losers from trade became reliant on the government. One supposed safety-net was “trade-adjustment assistance” (TAA), a programme dating from 1962 and beefed up after the signing of NAFTA. If the Department of Labour accepts a petition for TAA, workers get an extension to their unemployment-insurance payments. For most of the 2000s, the extension lasted six months. In addition, beneficiaries can enroll in training programmes; if they do, they receive more payments while they train. Workers over 50 also get a kind of wage insurance which pays up to $12,000 over two years to compensate them for starting a new job on lower pay.

Until 2009 TAA was more limited for those displaced by Chinese competition than by NAFTA, notionally because no free-trade deal had been signed with the Chinese. It covered only those whose factories had shut because of direct competition from Chinese imports. It left out those further up the supply chain, or those whose employers had moved factories to China. Some workers decided to claim disability benefits instead. Mr Autor and his colleagues found that in areas affected by trade with China, new spending on disability benefits was more than double new spending on unemployment insurance and TAA (see chart).

Even for those workers who did qualify for TAA, support was woefully inadequate. Only about a third entered training programmes, perhaps because the budget was so low: just $1,700 per displaced worker in 2007. The wage-insurance scheme was better than nothing, but was not enough to make up for wage losses which frequently exceeded 20%. The workers who lost the most in lifetime earnings—the young—were not eligible for wage insurance. In the aftermath of the recession TAA was improved, and Mr Obama now wants to expand wage insurance. But it is too late for those who lost out in the 2000s.

Obstructing their progress

How does this bear on today’s trade-policy debates? Economists were wrong to think in the 1990s that the concentrated costs of trade, which textbooks always predicted, had somehow been avoided. It is now clear that they can be, in fact, worse than first thought. But the gains from trade, which are larger still, were never an illusion. Trade sceptics sometimes seem to suggest that workers were better-off before the 1980s, because protectionism was rife but growth stayed high. Yet living standards today are far higher. Trade barriers, which prevent such advances, are a futile, self-defeating way to help the unskilled.

Today’s trade agreements are very different from NAFTA or other deals which have brought down tariffs, because most levies have already been abolished. Only 10% of the projected gains from TPP, for instance, come from tariff reductions. Where tariffs do fall in the TPP, America is primed to benefit. For example, Uncle Sam’s carmakers will cheer the end of big Malaysian and Vietnamese tariffs on motors.

The TPP’s biggest provisions concern protection for intellectual property, liberalising trade in services and enforcing stricter labour and environmental standards. All this probably helps American workers. Mr Autor and two of his most frequent co-authors support the deal, arguing that the globalisation of manufacturing is a fait accompli. Blocking the TPP or other modern trade deals will not undo the failure to help those who lost out from trade with China.

To the extent that some Americans are harmed, which is inevitable, the projected gains of future free-trade agreements should be more than enough to compensate losers, if only the government can get itself organised. Peter Petri and Michael Plummer, two economists, estimate that the TPP will boost American incomes by $131 billion, or 0.5% of GDP. That is over 100 times what America spent on trade-adjustment assistance in 2009: there is plenty of scope to do more for the losers from trade.

Many gains from trade remain on the table. Some hope that China may eventually join the TPP. China’s urban middle class will double over the next decade and seek services, from finance to telecoms, which America could compete to provide. The TPP includes restrictions on state-owned enterprises. China will be welcomed into the agreement only if it curtails subsidies to its national champions.

Europe presents another opportunity. Negotiators hope that the coming Transatlantic Trade and Investment Partnership will harmonise regulatory standards across the Atlantic in industries such as pharmaceuticals, telecoms and transport. Removing all such “non-tariff barriers” could raise America’s GDP by up to 3%, according to the most optimistic study. And the world has still to grapple with how best to regulate global flows of data—an issue in which America, as the world’s technology hub, has a huge stake.

Americans are not oblivious to these facts. A recent Gallup poll found that 58% see trade as an opportunity; only 34% see it as a threat. But this only reinforces the idea that the costs of trade are concentrated. Research shows that the more local workers compete with imports, the lower the number of votes cast for incumbent politicians—as the presidential hopefuls well know. If America is to go on reaping the gains from trade, it must ensure it compensates those who lose out. You can oppose protectionism, or you can oppose redistribution. It is getting harder to do both.