WHEN Jorge Castañeda (later Mexico’s foreign minister) was a boy, a typical family holiday was to drive to Texas. “[O]ne of the main purposes of the journey was to purchase fayuca: contraband electronics, food, clothes [and] gadgets of all sorts.” In their closed domestic market, Mexicans had few choices besides “obsolete TV sets…rancid peanut butter [and] highly flammable Terlenka windbreakers”. In the United States, they could buy good stuff cheaply. To smuggle it home, they would fill the car with hidden goodies, leaving a small TV ostentatiously visible. The customs officer would confiscate the TV and miss the rest.

Mexico has transformed itself. A generation ago it defended its borders ferociously against yanqui imports. Today, thanks partly to the North American Free-Trade Agreement (NAFTA), it is one of the most open large economies in the world. Exports plus imports will reach the equivalent of 69% of GDP this year, according to HSBC, a bank—far higher than Brazil (19%) or China (48%). It is the world’s second-largest exporter of fridges, and the second-largest supplier of electronic goods to the United States.

Location helps. No other emerging economy shares a long land border with the world’s biggest market. And soaring wages in China are making Mexico more competitive. In 2001 Mexican manufacturing wages were four times those in China; now the difference is trivial. Add in the price of fuel, and it is often as cheap to make things in Monterrey and drive them across the Rio Grande as to make them in Guangdong and ship them across the Pacific. It is also faster: a Mexican lorry can be in Michigan in a couple of days. Small wonder that Nissan, Honda, GM, Coca-Cola, DuPont and Eurocopter are rushing to invest south of the border.

Mexico is unusual in that it not only has a globalised elite but also a globalised peasantry. The rich study in the United States; the poor mop floors there. Both groups benefit their homeland. The elite pick up skills and contacts at American universities, which help Mexican firms do business with their giant neighbour. Migrant mop-wielders send money home to poor Mexican villages. The scale of border-straddling is colossal. One Mexican in ten lives in the United States—some 12m people. Add in the descendants of Mexicans born in the United States and the number is 33m. This creates a market for Mexican products: Corona is the most popular imported beer north of the border.

Mexico’s most dynamic firms tend to be cosmopolitan. Grupo Bimbo, Mexico’s biggest baker, is also America’s, having bought the North American baking arm of Sara Lee in 2011. Daniel Servitje, its Stanford-educated boss, switches easily between English and Spanish, and between home and abroad. Grupo Bimbo sells tortillas in the United States and American-style bagels in Mexico. Mr Servitje plans to invest $1 billion in the United States in the next five years to build zippier, cheaper bakeries. He aims to consolidate a business that has long been scattered like sprinkles on a cake. He wants to gain economies of scale, and to spread good ideas from one market to another. (The firm’s Mexican truckers take a four-day course in courtesy; other road-users notice the difference. This is less urgent in other countries.)

Other Mexican firms are spreading their wings, too. Cemex is the largest seller of certain types of cement in the United States. Alfa, a conglomerate, drills for gas in Texas. (Both firms’ bosses were at Stanford.) For a multinational, being based in Mexico is no longer a disadvantage. Raising capital is not hard; the Mexican bolsa is flavour of the month with foreign investors. Mexican firms are well-placed to expand north (where there are lots of Mexicans) or south (where Spanish is the lingua franca). Of the 19 countries where Grupo Bimbo operates, all but three are in the Americas (the others are Spain, Portugal and China).

There are still plenty of reasons to be gloomy about Mexican business. Crime is one: head-hacking drug gangs scare off tourists and shake down small firms. Yet the violence has barely touched big investors. The gangsters do not know whom to shake down at foreign car factories. Mr Servitje says his lorries are seldom robbed—bread is too bulky and perishable to be worth stealing.

Gangs, bungs and bureaucrats

Corruption is a bigger worry. Walmart’s rapid expansion in Mexico hit a bump this year when the American retailer revealed that it was investigating alleged bribes paid by its proxies to speed up permits to open new stores. The news surprised no one in Mexico. Local officials routinely drag their feet so that companies will pay them to hurry up. The World Bank’s Doing Business 2013 report finds that red tape is being cut: it ranks Mexican rules on such things as starting a firm and paying taxes 48th in the world—82 places better than Brazil. But Mexican mandarins still have the power to make life wretched for businesses.

Another criticism of Mexico’s global firms is that they have the muscle to venture abroad only because they earn oligopolistic profits at home. Carlos Slim, the world’s richest man, controls more than 70% of the Mexican mobile-phone market, which gives him ample cash to invest in foreign telecoms firms (and the New York Times, of which he owns 8%). Grupo Bimbo and Cemex have also used dominant positions at home as a springboard for overseas investments. Those investments have yet to prove their worth: Bimbo’s American foray has yet to earn more than the cost of capital, and Cemex’s has pushed it far into debt.

Yet the greatest threat to global Mexican firms is less subtle. It is the closing of that 2,000-mile border. Thanks to drones, deportations and economic doldrums, net migration from Mexico to the United States has tumbled to roughly zero. If Mexican students and workers find it too hard to move back and forth, they will eventually stay put. Connections will grow stale, like breadcrusts. That will be bad for business, and much besides.

Economist.com/blogs/schumpeter