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

A study published Thursday by the Pew Research Center said a desire to reunite families is the primary reason Mexicans go home. A sluggish U.S. 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 U.S. for Mexico from 2009 to 2014. During the same time, 870,000 Mexicans came to the U.S., 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 U.S. 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 U.S. 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 U.S. last year, down from a peak of 12.8 million in 2007. That includes 5.6 million living in the U.S. 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 U.S., mostly through South Texas, and many of them turned themselves in to authorities.

The authors analyzed U.S. 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 percent of those who reported living in the U.S. in 2009 but were back in Mexico last year had returned to join or start a family. An additional 14 percent had been deported, and 6 percent said they returned for jobs in Mexico.

Still, it's this lack of jobs in the U.S. — 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's less competition for young people looking for work there. That's 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 U.S. 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, airplanes 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 U.S. in 2005. "I could help them while I was there, but family comes before money."

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

Another telling statistic: 35 percent of adults in Mexico say they have friends or relatives they regularly communicate with or visit in the U.S., 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."