AGUA NEGRA, Mexico — The extraordinary Mexican migration that delivered millions of illegal immigrants to the United States over the past 30 years has sputtered to a trickle, and research points to a surprising cause: unheralded changes in Mexico that have made staying home more attractive.

A growing body of evidence suggests that a mix of developments — expanding economic and educational opportunities, rising border crime and shrinking families — are suppressing illegal traffic as much as economic slowdowns or immigrant crackdowns in the United States.

Here in the red-earth highlands of Jalisco, one of Mexico’s top three states for emigration over the past century, a new dynamic has emerged. For a typical rural family like the Orozcos, heading to El Norte without papers is no longer an inevitable rite of passage. Instead, their homes are filling up with returning relatives; older brothers who once crossed illegally are awaiting visas; and the youngest Orozcos are staying put.

“I’m not going to go to the States because I’m more concerned with my studies,” said Angel Orozco, 18. Indeed, at the new technological institute where he is earning a degree in industrial engineering, all the students in a recent class said they were better educated than their parents — and that they planned to stay in Mexico rather than go to the United States.

Douglas S. Massey, co-director of the Mexican Migration Project at Princeton, an extensive, long-term survey in Mexican emigration hubs, said his research showed that interest in heading to the United States for the first time had fallen to its lowest level since at least the 1950s. “No one wants to hear it, but the flow has already stopped,” Mr. Massey said, referring to illegal traffic. “For the first time in 60 years, the net traffic has gone to zero and is probably a little bit negative.”

The decline in illegal immigration, from a country responsible for roughly 6 of every 10 illegal immigrants in the United States, is stark. The Mexican census recently discovered four million more people in Mexico than had been projected, which officials attributed to a sharp decline in emigration.

American census figures analyzed by the nonpartisan Pew Hispanic Center also show that the illegal Mexican population in the United States has shrunk and that fewer than 100,000 illegal border-crossers and visa-violators from Mexico settled in the United States in 2010, down from about 525,000 annually from 2000 to 2004. Although some advocates for more limited immigration argue that the Pew studies offer estimates that do not include short-term migrants, most experts agree that far fewer illegal immigrants have been arriving in recent years.

The question is why. Experts and American politicians from both parties have generally looked inward, arguing about the success or failure of the buildup of border enforcement and tougher laws limiting illegal immigrants’ rights — like those recently passed in Alabama and Arizona. Deportations have reached record highs as total border apprehensions and apprehensions of Mexicans have fallen by more than 70 percent since 2000.

But Mexican immigration has always been defined by both the push (from Mexico) and the pull (of the United States). The decision to leave home involves a comparison, a wrenching cost-benefit analysis, and just as a Mexican baby boom and economic crises kicked off the emigration waves in the 1980s and ’90s, research now shows that the easing of demographic and economic pressures is helping keep departures in check.

In simple terms, Mexican families are smaller than they had once been. The pool of likely migrants is shrinking. Despite the dominance of the Roman Catholic Church in Mexico, birth control efforts have pushed down the fertility rate to about 2 children per woman from 6.8 in 1970, according to government figures. So while Mexico added about one million new potential job seekers annually in the 1990s, since 2007 that figure has fallen to an average of 800,000, according to government birth records. By 2030, it is expected to drop to 300,000.

Even in larger families like the Orozcos’ — Angel is the 9th of 10 children — the migration calculation has changed. Crossing “mojado,” wet or illegally, has become more expensive and more dangerous, particularly with drug cartels dominating the border. At the same time, educational and employment opportunities have greatly expanded in Mexico. Per capita gross domestic product and family income have each jumped more than 45 percent since 2000, according to one prominent economist, Roberto Newell. Despite all the depictions of Mexico as “nearly a failed state,” he argued, “the conventional wisdom is wrong.”

A significant expansion of legal immigration — aided by American consular officials — is also under way. Congress may be debating immigration reform, but in Mexico, visas without a Congressionally mandated cap on how many people can enter have increased from 2006 to 2010, compared with the previous five years.

State Department figures show that Mexicans who have become American citizens have legally brought in 64 percent more immediate relatives, 220,500 from 2006 through 2010, compared with the figures for the previous five years. Tourist visas are also being granted at higher rates of around 89 percent, up from 67 percent, while American farmers have legally hired 75 percent more temporary workers since 2006.

Edward McKeon, the top American official for consular affairs in Mexico, said he had focused on making legal passage to the United States easier in an effort to prevent people from giving up and going illegally. He has even helped those who were previously illegal overcome bans on entering the United States.

“If people are trying to do the right thing,” Mr. McKeon said, “we need to send the signal that we’ll reward them.”

Hard Years in Jalisco

When Angel Orozco’s grandfather considered leaving Mexico in the 1920s, his family said, he wrestled with one elemental question: Will it be worth it?

At that point and for decades to come, yes was the obvious answer. In the 1920s and ’30s — when Paul S. Taylor came to Jalisco from California for his landmark study of Mexican emigration — Mexico’s central highlands promised little more than hard living. Jobs were scarce and paid poorly. Barely one of three adults could read. Families of 10, 12 and even 20 were common, and most children did not attend school.

Comparatively, the United States looked like a dreamland of technology and riches: Mr. Taylor found that the wages paid by the railroads, where most early migrants found legal work, were five times what could be earned on farms in Arandas, the municipality that includes Agua Negra.

Orozco family members still talk about the benefits of that first trip. Part of the land the extended family occupies today was purchased with American earnings from the 1920s. When Angel’s father, Antonio, went north to pick cotton in the 1950s and ’60s with the Bracero temporary worker program, which accepted more than 400,000 laborers a year at its peak, working in the United States made even more sense. The difference in wages had reached 10 to 1. Arandas was still dirt poor.

Antonio, with just a few years of schooling, was one of many who felt that with a back as strong as a wooden church door, he could best serve his family from across the border.

“I sent my father money so he could build his house,” Antonio said.

Legal status then meant little. After the Bracero program ended in 1964, Antonio said, he crossed back and forth several times without documentation. Passage was cheap. Work lasting for a few months or a year was always plentiful. So when his seven sons started to become adults in the 1990s, he encouraged them to go north as well. Around 2001, he and two of his sons were all in the United States working — part of what is now recognized as one of the largest immigration waves in American history.

But even then, illegal immigration was becoming less attractive. In the mid-1990s, the Clinton administration added fences and federal agents to what were then the main crossing corridors beyond Tijuana and Ciudad Juárez. The enforcement push, continued by President George W. Bush and President Obama, helped drive up smuggling prices from around $700 in the late 1980s to nearly $2,000 a decade later, and the costs continued to climb, according to research from the Center for Comparative Immigration Studies at the University of California, San Diego. It also shifted traffic to more dangerous desert areas near Arizona.

Antonio said the risks hit home when his nephew Alejandro disappeared in the Sonoran Desert around 2002. A father of one and with a pregnant wife, Alejandro had been promised work by a friend. It took years for the authorities to find his body in the arid brush south of Tucson. Even now, no one knows how he died.

But for the Orozcos, border enforcement was not the major deterrent. Andrés Orozco, 28, a middle son who first crossed illegally in 2000, said that while rising smuggling costs and border crime were worries, there were always ways to avoid American agents. In fact, while the likelihood of apprehension has increased in recent years, 92 to 98 percent of those who try to cross eventually succeed, according to research by Wayne A. Cornelius and his colleagues at the University of California, San Diego.

A Period of Progress

Another important factor is Mexico itself. Over the past 15 years, this country once defined by poverty and beaches has progressed politically and economically in ways rarely acknowledged by Americans debating immigration. Even far from the coasts or the manufacturing sector at the border, democracy is better established, incomes have generally risen and poverty has declined.

Here in Jalisco, a tequila boom that accelerated through the 1990s created new jobs for farmers cutting agave and for engineers at the stills. Other businesses followed. In 2003, when David Fitzgerald, a migration expert at the University of California, San Diego, came to Arandas, he found that the wage disparity with the United States had narrowed: migrants in the north were collecting 3.7 times what they could earn at home.

That gap has recently shrunk again. The recession cut into immigrant earnings in the United States, according to the Pew Hispanic Center, even as wages have risen in Mexico, according to World Bank figures. Jalisco’s quality of life has improved in other ways, too. About a decade ago, the cluster of the Orozco ranches on Agua Negra’s outskirts received electricity and running water. New census data shows a broad expansion of such services: water and trash collection, once unheard of outside cities, are now available to more than 90 percent of Jalisco’s homes. Dirt floors can now be found in only 3 percent of the state’s houses, down from 12 percent in 1990.

Still, education represents the most meaningful change. The census shows that throughout Jalisco, the number of senior high schools or preparatory schools for students aged 15 to 18 increased to 724 in 2009, from 360 in 2000, far outpacing population growth. The Technological Institute of Arandas, where Angel studies engineering, is now one of 13 science campuses created in Jalisco since 2000 — a major reason professionals in the state, with a bachelor’s degree or higher, also more than doubled to 821,983 in 2010, up from 405,415 in 2000.

Similar changes have occurred elsewhere. In the poor southern states of Chiapas and Oaxaca, for instance, professional degree holders rose to 525,874 from 244,322 in 2000.

And the data from secondary schools like the one the Orozcos attended in Agua Negra suggests that the trend will continue. Thanks to a Mexican government program called “schools of quality” the campus of three buildings painted sunflower yellow has five new computers for its 71 students, along with new books.

Teachers here, in classrooms surrounded by blue agave fields, say that enrollment is down slightly because families are having fewer children, and instead of sending workers north, some families have moved to other Mexican cities — a trend also found in academic field research. Around half the students now move on to higher schooling, up from 30 percent a decade ago.

“They’re identifying more with Mexico,” said Agustín Martínez González, a teacher. “With more education, they’re more likely to accept reality here and try to make it better.”

Some experts agree. Though Mexicans with Ph.D.’s tend to leave for bigger paychecks abroad, “if you have a college degree you’re much more likely to stay in Mexico because that is surely more valuable in Mexico,” said Jeffrey S. Passel, a demographer at the Pew Hispanic Center.

If these trends — particularly Mexican economic growth — continue over the next decade, Mr. Passel said, changes in the migration dynamic may become even clearer. “At the point where the U.S. needs the workers again,” he said, “there will be fewer of them.”

Praying for Papers

The United States, of course, has not lost its magnetic appeal. Illegal traffic from Central America has not dropped as fast as it has from Mexico, and even in Jalisco town plazas are now hangouts for men in their 30s with tattoos, oversize baseball caps and a desire to work again in California or another state. Bars with American names — several have adopted Shrek — signal a back and forth that may never disappear.

But more Mexicans are now traveling legally. Several Orozco cousins have received temporary worker visas in the past few years. In March, peak migration season for Jalisco, there were 15 people from Agua Negra at the border waiting to cross.

“And 10 had visas,” said Ramón Orozco, 30, another son of Antonio who works in the town’s government office after being the first in his family to go to college. “A few years ago there would have been 100, barely any with proper documents.”

This is not unique to Agua Negra. A few towns away at the hillside shrine of St. Toribio, the patron saint of migrants, prayers no longer focus on asking God to help sons, husbands or brothers crossing the desert. “Now people are praying for papers,” said María Guadalupe, 47, a longtime volunteer.

How did this happen?

Partly, emigrants say, illegal life in the United States became harder. Laws restricting illegal immigrants’ rights or making it tougher for employers to hire them have passed in more than a dozen states since 2006. The same word-of-mouth networks that used to draw people north are now advising against the journey. “Without papers all you’re thinking about is, when are the police going to stop you or what other risks are you going to face,” said Andrés Orozco.

Andrés, a horse lover who drives a teal pickup from Texas, is one of many Orozcos now pinning their hopes on a visa. And for the first time in years, the chances have improved.

Mexican government estimates based on survey data show not just a decrease in migration overall, but also an increase in border crossings with documents. In 2009, the most recent year for which data is available, 38 percent of the total attempted crossings, legal and illegal, were made with documents. In 2007, only 20 percent involved such paperwork.

The Mexican data counts attempted crossings, not people, and does not differentiate between categories of visas. Nor does it mention how long people stayed, nor whether all the documents were valid.

Advocates of limited immigration worry that the issuing of more visas creates a loophole that can be abused. Between 40 and 50 percent of the illegal immigrants in the United States entered legally with visas they overstayed, as of 2005, according to the Pew Hispanic Center.

More recent American population data, however, shows no overall increase in the illegal Mexican population. That suggests that most of the temporary visas issued to Mexicans — 1.1 million in 2010 — are being used legitimately even as American statistics show clearly that visa opportunities have increased.

Easing a Chaotic Process

One man, Mr. McKeon, the minister counselor who oversees all consular affairs in Mexico, has played a significant role in that expansion.

A lawyer with a white beard and a quick tongue, Mr. McKeon arrived in the summer of 2007. And after more than 30 years working in consular affairs in China, Japan and elsewhere, he quickly decided to make changes in Mexico. Working within administrative rules, State Department officials say, he re-engineered the visa program to de-emphasize the affordability standard that held that visas were to be denied to those who could not prove an income large enough to support travel to the United States.

In a country where a person can cross the border with a 25-cent toll, Mr. McKeon said, the income question was irrelevant. “You have to look at everyone individually,” he said in an interview at his office in Mexico City. “I don’t want people to say, here’s the income floor, over yes, lower no.”

This led to an almost immediate decrease in the rejection rate for tourist visas. Before he arrived, around 32 percent were turned down. Since 2008, the rate has been around 11 percent.

Mr. McKeon — praised by some immigration lawyers for bringing consistency to a chaotic process — was also instrumental in expanding the temporary visa program for agricultural workers. Called H-2A, this is one of the few visa categories without a cap.

Around 2006, as the debate over immigration became more contentious, employers concentrated in the Southeast began applying for more workers through the program. Mr. McKeon began hosting conferences with all the stakeholders and deployed new technology and additional staff members. The waiting time for several visa categories decreased, government reports show. For H-2As, Mexican workers can now receive their documents the same day that they apply.

Mr. McKeon also pushed to make the program more attractive to Mexicans who might otherwise cross the border illegally. Two years ago, he eliminated a $100 visa issuance fee that was supposed to be covered by employers but was usually paid by workers. And he insisted that his staff members change their approach with Mexicans who had previously worked illegally in the United States.

“The message used to be, if you were working illegally, lie about it or don’t even try to go legally because we won’t let you,” said one senior State Department official. “What we’re saying now is, tell us you did it illegally, be honest and we’ll help you.”

Specifically, consulate workers dealing with H-2A applicants who were once illegal — making them subject to 3- or 10-year bans depending on the length of their illegal stay — now regularly file electronic waiver applications to the United States Customs and Border Patrol. About 85 percent of these are now approved, Mr. McKeon said, so that in 2010 most of the 52,317 Mexican workers with H-2A visas had previously been in the United States illegally.

“It’s not easy to go through this process,” Mr. McKeon said, “and I think people who are willing to go through all of that and risk going back to the United States where they have to pay taxes, and withholding, I think we should look favorably on them.”

Speaking as the son of a New Jersey plumber, he added: “My bias is toward people who sweat at work because I really think that’s the backbone of our country. With limited resources, I’d rather devote our efforts to keeping out a drug kingpin than trying to find someone who works a couple of months at Cousin Hector’s body shop.”

A Divisive Topic

In the heated debate over immigration, however, this topic is inevitably divisive. Pro-immigrant groups, when told of the expansion to legal immigration, say it still may not be enough in a country where the baby boomers are retiring in droves.

Farmers still complain that the H-2A visa program is too complicated and addresses only a portion of the total demand. As of 2010, there were 1,381,896 Mexicans still waiting for their green-card applications to be accepted or rejected. And the United States currently makes only 5,000 green cards annually available worldwide for low-wage workers to immigrate permanently; in recent years, only a few of those have gone to Mexicans.

On the other side, Steven A. Camarota, a demographer at the Center for Immigration Studies in Washington, which favors reduced immigration, said that increasing the proportion of legal entries did little good.

“If you believe there is significant job competition at the bottom end of the labor market, as I do, you’re not fixing the problem,” Mr. Camarota said. “If you are concerned about the fiscal cost of unskilled immigration and everyone comes in on temporary visas and overstays, or even if they don’t, the same problems are likely to apply.”

By his calculations, unskilled immigrants like the Orozcos have, over the years, helped push down hourly wages, especially for young, unskilled American workers. Immigrants are also more likely to rely on welfare, he said, adding to public costs.

The Orozco clan, however, may point to a different future. Angel Orozco, like many other young Mexicans, now talks about the United States not as a place to earn money, but rather as a destination for fun and spending.

Today he is just a lanky, shy freshman wearing a Daughtry T-shirt and living in a two-room apartment with only a Mexican flag and a rosary for decoration.

But his dreams are big and local. After graduating, he said, he hopes to work for a manufacturing company in Arandas, which seems likely because the director of his school says that nearly 90 percent of graduates find jobs in their field. Then, Angel said, he will be able to buy what he really wants: a shiny, new red Camaro.