THESE are dark days for globalisation. In America, presidential candidates are talking about building walls and unpicking trade deals. Brazil, another giant of the Americas, seems as protectionist as ever. Britain is preparing to hold a referendum on withdrawing from the European Union. The EU as a whole is bickering over what to do about a swelling tide of refugees.

Yet there is at least some light in the darkness. Mexico, for instance, continues to carry a torch for globalisation. President Enrique Peña Nieto’s administration boasts about the country’s 44 trade deals, more than any other country, and its 11 reform initiatives. The World Bank calculates that Mexico is one of the most open large economies in the world: exports plus imports are equivalent to 66% of GDP, compared with 26% for Brazil and 42% for China. The Boston Consulting Group finds in a survey that its people take a positive view of the future: 77% of Mexicans say they are optimistic, and only 6% that they are very pessimistic. Mexicans see the likes of Donald Trump as being cut from the same cloth as the old-fashioned Latin American strongmen who ruined the region through protectionism and gesture politics.

When the North American Free Trade Area (NAFTA) was created in 1994 it was as controversial in Mexico as it was in the United States: a Yanqui conspiracy, according to those on the left, designed to turn their country into a colony of El Norte. Today the Mexican elite speaks with one voice on the subject. Mexico is now one of the world’s top 15 manufacturing economies and one of its top five car producers. The output of the ten largest car plants rose from 1.1m vehicles in 1994 to 2.9m in 2012. Mexican consumers now have access to a huge range of multinational brands: marketers refer to young, middle-class Mexicans as the “children of NAFTA”, because their taste is so cosmopolitan.

Free trade has helped to produce a corps of elite Mexican companies that are capable of going head-to-head with the best in the world. Bimbo is the world’s largest baker, thanks in part to its ambitious expansion into America with the purchase of Sara Lee’s bakery business. Gruma is the world’s biggest maker of tortillas, with more than 100 plants in 20 countries. Free trade has been a double blessing for such companies. First, it has encouraged those that have reached the limit of the Mexican market to go global. They have the huge advantages of speaking one of the world’s most popular languages, and sharing a 1,900-mile (3,100km) border with America. Second, now that they are more vulnerable to competition and takeovers, they have been forced to shake off a long-standing tendency for successful Mexican companies to become flabby. When AB InBev, a global brewer, bought Grupo Modelo, a Mexican beer firm, in 2013, it quickly eliminated around $1 billion in annual costs.

Schumpeter noted in a previous column on Mexico that it is unusual in having both a global upper class (thanks to American education) and a global peasantry (thanks to emigration to America). Free trade is now rapidly globalising the middle class, which by some estimates makes up 30-40% of the population. Scot Rank, the boss of the Lala Group, a dairy firm, points out that better-off Mexicans are becoming more like Americans in their tastes. They want “lite” products that will help them fight the flab (obesity is a big problem in a country addicted to a “vitamin T” diet of tacos and tortillas) and “drinkables”, nutrition that can be consumed on the go (partly in response to the rise of two-income families).

Mexico is now freeing up two hitherto protected areas, telecoms and energy. Telmex has been forced to surrender its telecoms monopoly, and is now in a vigorous battle with the Yanqui AT&T, in which average tariffs have fallen by half in the past year. Pemex, the state oil monolith, is being forced to auction off some fields to foreign bidders, and to form joint ventures with foreign firms. A visit to Pemex’s headquarters illustrates just how radical the latter policy is. A collection of giant slabs surrounded by thick iron railings, protected by a phalanx of armed guards, it looks more like an arm of government than a commercial organisation. Which is exactly what it is: Pemex provides a third of government revenues and thousands of coveted jobs—and until recently its monopoly status was guaranteed in the constitution. Last month the government underlined its seriousness by sacking the company’s boss, Emilio Lozoya, despite his close relationship with the president. The new boss, José Antonio González, argues that the steep fall in the oil price is also a “golden opportunity”: Pemex now has no choice but to reform if it is to thrive in the face of greater competition.

The other Mexico that still needs fixing

Even if the government can successfully re-engineer Pemex, it still has an enormous amount to do. Mexico is one of the world’s most unequal societies. Perhaps half of Mexicans are still poor and parochial, beset by crime and corruption, and poorly served by schools and banks. The economy is hobbled by a long tail of inefficient firms: the McKinsey Global Institute, a think-tank, points out that, though the productivity of Mexico’s globalised companies has risen by 5.8% a year since 1999, the productivity of small, traditional firms has fallen by 6.5% a year. Poorer regions, especially in the south, are mired in the past, too far from the American border to benefit from the manufacturing boom. These problems have held back the economy’s growth rate to a disappointing 2-3% over the past 30 years. They have also supplied the drugs cartels (which benefit from globalisation in their own, malign way) with an endless supply of young recruits.

Mr Peña Nieto’s administration has done something to extend the benefits of globalisation to this other Mexico by deregulating telecoms and taking on the teachers’ unions. However, this is just the start of what is needed. Successful Mexicans are right to mock Mr Trump’s talk of building walls. But they need to focus their energies on some construction projects of their own: building ladders of opportunity for the poor, and bridges of commerce between the two Mexicos.