The number of undocumented Mexican immigrants has declined so dramatically during the past decade that they no longer make up the majority of those living illegally in the United States.

That’s the finding of a Pew Research Center study, based on government data, that was released Wednesday.

The decrease among Mexican migrants was the main factor in driving down the total population of undocumented people in this country, which in 2017 was 10.5 million, about 1.7 million less than the 2007 peak of 12.2 million.

The undocumented migrants that Pew estimated included 4.9 million Mexicans. While Mexicans remain a larger percentage of undocumented immigrants than those from any other country, their 47 percent share in 2017 amounted to less than a majority for the first time in more than 50 years, since a major overhaul of government immigration policy in 1965.

That year, the Immigration and Naturalization Act abolished a quota system that favored Europeans and established policies that focused on reuniting families and attracting skilled labor.

The new Pew report said the number of Mexicans had declined since the mid-2000s for the simplest of reasons — more left the U.S. than arrived.

But within that basic explanation rests a multitude of influences on both sides of the border: the strength of the U.S economy, particularly its ability to spin off jobs that are attractive to those without paperwork; the Mexican economy, which has been strong despite a recent downturn, keeping more people home; the dramatic increase in U.S. border security; the rise in deportations from this country — up 13 percent between fiscal 2017 and 2018. Even the declines in Mexican birthrates may play a role.

Meanwhile, more newcomers are arriving in the U.S. from Asian lands, bringing with them greater English fluency and formal education.

The study arrives as President Donald Trump continues to attack Mexico over immigration.

He had threatened to impose tariffs, but held off upon announcing a deal with Mexico last week that would curtail the flow of migrants from Central America. The president said he would reimpose tariffs if Mexico failed to follow through. Trump has pledged to build a wall at the Mexican border, and make Mexico pay for it, having disparaged immigrants from that country as rapists and criminals during his presidential campaign.

The total number of undocumented Mexican immigrants has dropped by 2 million since a peak of 6.9 million in 2007, and was lower in 2017 than in any year since 2001, Pew said.

Similarly, the number of apprehensions of Mexicans at the U.S. border fell over the decade. Apprehensions of non-Mexicans surpassed those of Mexicans for the past three fiscal years, according to federal statistics cited by Pew.

As the number of undocumented Mexican migrants decreased, those from other parts of the world increased, Pew said. An estimated 5.5 million non-Mexican migrants lived in the U.S. in 2017, compared with 5.3 million in 2007.

The decline from Mexico and the increase from other countries shows the change in how undocumented migrants are entering the country. A growing share do not cross the border, but instead most likely arrive with legal visas, then overstay their required departure date.

Those “likely overstays” have made up a majority of undocumented arrivals since 2010, according to Pew.

From 2007 to 2017, the undocumented population grew in five states — Louisiana, Maryland, Massachusetts, North Dakota and South Dakota — and declined in 12. Those with declines included five of the six states with the largest undocumented populations: California, Florida, Illinois, New York, and New Jersey.

The Garden State saw a drop of about 110,000, Pew said, from roughly 550,000 to 450,000. The agency said it could not speculate on the reasons for that.

Pennsylvania, home to about 190,000 undocumented immigrants, saw no statistically significant change, Pew said.

The center’s total estimate of undocumented immigrants in the United States includes 1.5 million or more people who have temporary permission to live here, but could face deportation through changes in government policy.

In 2017, they included about 320,000 people from 10 countries with Temporary Protected Status, afforded to people from homelands riven by war or natural disaster, and about 700,000 beneficiaries of Deferred Action for Childhood Arrivals, known as DACA, which supports those who were brought here illegally as children. It also includes a growing number of people who have applied for asylum.

Despite the decline over the decade, the number of undocumented immigrants in the U.S. in 2017 was triple the 3.5 million in 1990. Undocumented migrants made up 23 percent of the 45.6 million foreign-born residents in the United States in 2017, Pew said.

Pew calculated its estimate this way: The research center started with census data and government surveys, such as the American Community Survey, to determine how many immigrants were living in the U.S. in a particular year. Then it used official counts of legal immigrant admissions, including refugees, those seeking asylum, and other entrants, as well as additional data such as death rates and counts of migrants leaving the U.S., to determine how many immigrants were living here with government permission.

Pew then subtracted the number of legal immigrants from the total number of immigrants. That provided an estimate of the undocumented population.

But from experience and research, Pew knew that the Census Bureau and other official surveys can miss people when counting. And that undocumented immigrants are especially likely to be missed. So it applied Census Bureau studies of undercounts and data from the Mexican government to produce a final estimate that included an upward adjustment to reflect undercount.