THE history of Latin American emigration is best told over lunch. Taco and tostada stalls have spread across the United States because 12m Mexicans have settled there. In Madrid, steaks sizzle on parrillas tended by Argentines who fled the economic crisis of the early 2000s. To wash such delicacies down, bars in any big city serve mojitos mixed by Cuban exiles.

These days culinary ideas flow both ways. Mexico City is full of Spanish tapas bars. New Portuguese bakeries are springing up in São Paulo. Even American eateries are proliferating south of the border. The reason is that Latin America has become a destination as well as departure point for enterprising migrants.

As rich countries stagnate, they cease to be magnets for mobile hands and brains. Net migration from Mexico to the United States has fallen to roughly zero. In Spain, where more than half of young people are unemployed, the number emigrating each year to Latin America trebled in the five years to 2011. “Necessity has made them overcome the fear of moving abroad for work,” says Juan José Ribas, a Spaniard based in Costa Rica as regional head of Barceló, a Spanish travel company with 29 hotels in Latin America. Barceló now gets so many job inquiries from Spanish would-be émigrés that it no longer has to advertise its Latin American vacancies, Mr Ribas says.

In Portugal, where the economy shrank in four of the past five years, a generation of young Magellans has set off seeking work. Brazil now admits more immigrants (legal ones, at least) from Europe and the United States than from Latin America. Remittances from Brazil to Portugal are greater than those from Portugal to Brazil, says the World Bank. The same is true between Mexico and Spain. Spaniards in Argentina send home more than $1 billion a year, four times the amount that flows in the other direction.

Those who move often find they can learn more and advance faster than they could have back home. “Mexico is giving me an opportunity to grow professionally which would be hard to find in Europe,” says Jorge Laínez, a young Ibizan who moved west in 2010 to be country manager of McBains Cooper, a British property consultancy. The lifestyle is a bonus: Mr Laínez’s Mexico City office is 15 minutes by rented bicycle from his home.

Foreign firms are flocking to Latin America to service its new middle class. When starting up, most send expatriates to manage their operations. French executives in Mexico are overseeing a new cosmetics industry, which includes the world’s biggest hair-dye factory, opened in December by L’Oréal. In January Volkswagen inaugurated a big new engine plant to complement its gigantic car factory in Puebla (where a pumpernickel bakery feeds some of the 90 German VW executives based in Mexico).

Latin American firms are also snapping up immigrants. Manpower, a recruitment firm, says that 71% of Brazilian employers have difficulty filling jobs. Brazil’s expanding economy has created 12.5m new formal jobs in the past eight years, even though growth has slowed of late. Having expanded so suddenly, Brazil faces a shortage of people with experience, says Riccardo Barberis, an Italian who heads Manpower in Brazil. That means that bright sparks, Brazilian or otherwise, can charge a premium, which in turn makes Brazil a more tempting destination for migrants. Oil-and-gas engineers can earn perhaps 20% more in Brazil than in Europe, says Mr Barberis.

In the long run Latin countries could address their skills shortages by fixing their schools, which are bad. Mexican pupils score no better on tests than those in Thailand and Romania, which are much poorer countries. Brazil is even worse.

But things are looking up: Brazil has increased enrolment and Mexico recently arrested the leader of its teachers’ union, on charges of stealing more than $150m of union money to splurge on handbags and cosmetic surgery. (She denies it.) In some fields local skills have improved. “Ten or 15 years ago you would go to a big banking pitch in Brazil and [the bankers] would all be Americans flown in for the day. Now they are all Brazilians,” says Damian Fraser, a Briton who runs the Mexican office of UBS, an investment bank. The banks winning business are increasingly local ones as well.

Roll out the bienvenido mat

Even so, Latin firms would still benefit from easy access to foreign talent, knowledge and connections. Alas, many governments make hiring foreigners difficult. It can take six months to get a Brazilian visa. UBS has been waiting months to transfer a Portuguese analyst to its São Paulo offices, and was unable to transfer a Danish employee to Brazil because the financial-services exam can be sat only in Portuguese. Inefficient ports and high customs duties make relocation expensive. Once in, it is difficult to leave Brazil: departing expats must be prepared to submit to an inspection of their possessions to check that no cultural patrimony is being stolen. The government recently announced speedier visas for IT workers. For everyone else the process remains painful.

Even Mexico, a tenth of whose citizens live abroad and whose economy is more open than that of any other country its size, remains atavistically touchy about outsiders. Foreigners cannot buy property along its borders or coast (national security, you understand), or invest in certain industries. Oil remains in the ground because gringos are barred from investing in extracting it. Even foreign-born Mexican citizens cannot serve in the cabinet.

It is not surprising that Latin America is bad at managing immigration: for years it has had little to deal with. Whereas 13% of people in the United States and Britain were born abroad, in Mexico the figure is less than 1%. In Brazil it is 0.3%. As Latin America booms, its foreign-born population will swell. Employing clever foreigners will help its firms thrive.

Economist.com/blogs/schumpeter