More Mexicans are leaving the United States than migrating into the country, marking a reversal of one of the most significant immigration trends in US history.

A study published on Thursday by the Pew Research Center said a desire to reunite families is the primary reason Mexicans go home. A sluggish US recovery from the Great Recession also contributed. Meanwhile, tougher border enforcement has deterred some Mexicans from coming to the United States.

Pew found that slightly more than 1 million Mexicans and their families, including American-born children, left the US for Mexico from 2009 to 2014. During the same time, 870,000 Mexicans came to the US, resulting in a net flow to Mexico of 140,000.

A half-century of mass migration from Mexico is “at an end”, said Mark Hugo Lopez, Pew’s director of Hispanic research.

The finding follows a Pew study in 2012 that found net migration between the two countries was near zero, so this represents a turning point in one of the largest mass migrations in US history. More than 16 million Mexicans moved to the United States from 1965 to 2015, more than from any other country.

“This is something that we’ve seen coming,” Lopez said. “It’s been almost 10 years that migration from Mexico has really slowed down.”

The findings counter the narrative of an out-of-control border that has figured prominently in US presidential campaigns, with Republican Donald Trump calling for Mexico pay for a fence to run the entire length of the 1,954-mile frontier. Pew said there were 11.7 million Mexicans living in the US last year, down from a peak of 12.8 million in 2007. That includes 5.6 million living in the US illegally, down from 6.9 million in 2007.

In another first, the border patrol arrested more non-Mexicans than Mexicans in the 2014 fiscal year, as more Central Americans came to the US, mostly through south Texas, and many of them turned themselves in to authorities.

The authors analyzed US and Mexican census data and a 2014 survey by Mexico’s National Institute of Statistics and Geography. The Mexican questionnaire asked about residential history, and found that 61% of those who reported living in the US in 2009 but were back in Mexico last year had returned to join or start a family. An additional 14% had been deported, and 6% said they returned for jobs in Mexico.

Still, it is this lack of jobs in the US – not family ties – that is mostly motivating Mexicans to leave, said Dowell Myers, a public policy professor at the University of Southern California. Construction is a huge draw for young immigrants, but has yet to approach the levels of last decade’s housing boom, he said.

“It’s not like all of a sudden they decided they missed their mothers,” Myers said. “The fact is, our recovery from the Great Recession has been miserable. It’s been miserable for everyone.”

Also, Mexico’s population is aging, meaning there is less competition for young people looking for work there. That is a big change from the 1990s, when many people entering the workforce felt they had no choice but to migrate north of the border, Myers said.

While the US economic recovery is sluggish, Mexico has been free in recent years from the economic tailspins that drove earlier generations north in the 1980s and 1990s. The peso is relatively stable, inflation is manageable, and while many parts of Mexico suffer grinding poverty and violence, others – especially in the more industrial northern half – have become thriving manufacturing centers under the North American Free Trade Agreement, producing cars, aircraft and other heavy equipment.

“The main reason for my return is family,” José Arellano Correa, a 41-year-old Mexico City taxi driver who came back from the US in 2005. “I could help them while I was there, but family comes before money.”

Mexicans who remain in the US are more settled than before, Pew said. Their median age was 39 years in 2013, compared with 29 in 1990. More than three in four had been in the US for more than a decade, compared with only half in 1990.

Another telling statistic: 35% of adults in Mexico say they have friends or relatives they regularly communicate with or visit in the US, a Pew survey this year found. That’s down 7 percentage points from 2007.

Guadalupe Romo, 49, has lived in Fresno, California, for 26 years and has no plans to leave.

“We have our life here,” she said at Fresno’s Mexican consulate. “There’s no point in going back to Mexico.”