Thirty years ago, Lourdes Huesca and her husband moved to a tiny patch of land in the muddy bean fields at the edge of Mexico City. The young couple lived in a shack, with no water or electricity, in the poor, rural, old Mexico.

Huesca, who never learned to read but could add numbers in her head, marched her sons to the schoolhouse every day. The family struggled, sacrificed, saved.

A generation later, the family owns a shoe stall in the market and a nice cement-block home with three bedrooms, landscape oil paintings on the wall, and a new flat-screen TV, a gift from the eldest son, an environmental systems engineer.

“Mexico has given me so much,” Huesca said.

But she knows how easy it would be for her family to fall back down again in a country where social mobility too often moves in the wrong direction.

By a wide range of social and economic indicators, Mexico has reached a turning point, development experts say. The country is no longer poor, though it is a long way from being rich. Huesca and a narrow majority of Mexico’s 114 million citizens have clawed their way into an emerging middle class.

The changes are transforming Mexico’s relationship with the United States. The once-wary neighbors are now top trading partners, with more than $1 billion in goods crossing the border each day. Together, Mexican and U.S. workers manufacture automobiles, airplanes, computers and space satellites.

A more solidly middle-class and open Mexico is also providing a close-to-home market for U.S. goods and services, while contributing to a reduction in the number of underemployed Mexicans heading north to work illegally in the United States.

But in fundamental ways, Mexico is still far from completing its transformation from a mostly poor country of low wages and low expectations into a richer, better-educated and more competitive nation, a modern success story.

Many middle-class Mexicans are barely making it.

Huesca, 53, is healthy, but her husband has diabetes, and because the couple worked in the informal economy all their lives, they have no health insurance, no social security. When they go to the doctor, they pay cash. They have no pensions, no savings and no assets, except the family home on a dirt street.

Two of their sons have graduated from college. A third is finishing up at a public university. But if anyone in the family loses a job, or gets seriously ill, Huesca could quickly join the 3 million Mexicans who slid from the middle class back into poverty during the last recession.

Falling income inequality in Mexico

About 17 percent of Mexicans joined the ranks of the middle class from 2000 to 2010, according to a recent World Bank report, and though the traditionally wide gap between country’s rich and poor persists, measures of inequality among citizens fell more in Mexico than in any other Latin American country, except Peru.

But Mexico — with the 13th-largest economy in the world, built on booming free trade with the United States — still functions far below its competitors, according to analysis by its own leaders in the World Bank and the Organization for Economic Cooperation and Development (OECD), a club of 34 developed countries.

In Mexico, middle-class workers earn an income closer to the wages at the bottom than the top. Disparity is great. The bottom 10 percent receives just 1.3 percent of total income, while the top 10 percent receives 36 percent.

The nation’s relatively anemic growth and lingering inequalities — compared with regional rivals such as Brazil and Chile, or economic rivals such as South Korea and Turkey — condemn millions to a tenacious poverty that hangs like an anchor around Mexico’s neck.

The country’s new president, Enrique Peña Nieto vows to raise 15 million people from poverty in the next six years by tripling economic growth, providing loans to small and medium businesses, and tearing down the walls that have insulated monopolies and the elite from competition.

It is an ambitious agenda, one that his predecessor, Felipe Calderon, never achieved in a term during which poverty rose as the 2009 global economic crisis took its toll, despite soaring public spending on social welfare programs.

Gains and pains

Mexico’s struggle to secure a better future is plain to see in edge cities such as Chalco, no longer a slum but not quite the suburbs, where ordinary families tell of how hard it is to make it in Mexico.

The Chalco Valley, once the shoreline of a shallow lake fished by Aztec vassals, was a sleepy dairy pasture for most of the 20th century. After the devastating Mexico City earthquake of 1985, refugees from the capital turned a backwater into a gritty, mercantile metropolis.

Now the Chalco Valley is home to 850,000 residents and is filled with new schools, clinics and playgrounds built by the government, with Wal-Marts and AutoZones rising from cement-block barrios that 25 years ago lacked running water.

“In 1976, there were two primary schools in Chalco,” said Mayor Esteban Hernandez. “Today, we have 380 schools, including six universities.”

The mayor said education, more than anything else, has changed the fortunes of Mexico. “If the kids can go to school,” Hernandez said, “then the mother can work, and the family income rises, and the child gets an education.”

Mexico can afford to educate more children because its population is no longer exploding. The nation’s fertility rate in the 1960s was seven children per mother; today, it is two per mother.

Lourdes Huesca came from a family of 10 siblings. But she and her husband have only three sons, “and to me, that’s a lot,” she said.

“I told my sons they were going to get an education,” Huesca said.

All three went to college.

Her youngest is enrolled at the National Polytechnic Institute, the “MIT of Mexico,” where tui­tion, books and bus fare cost the family about $200 a semester. He wants to be a computer engineer.

“Once my third son finishes his studies,” Huesca said, “my life will be complete.”

Her children are the exception.

Nearly all Mexican children ages 5 to 14 are in school, a tremendous advance. But only 20 percent of 25- to 34-year-olds have gotten a college education, compared with 37 percent across other OECD countries.

According to surveys of school principals, 70 percent of Mexican teachers — who belong to one of the most powerful unions in Latin America, run by a boss with lifetime tenure — arrive to work late, are not prepared for their classes or routinely fail to show up.

The other economy

Mexico’s illicit economy — including a thriving black market — is still the fastest way forward for many, reflecting a rampant criminality that drags the country down.

Eva Ortiz has made a decent middle-class life for her family by selling pirated DVDs in the Chalco market. Orphaned as an infant, she was a maid at age 10, an abuse victim at 14 and a mother at 15.

She didn’t spend a single day of her childhood in a classroom.

Instead, she began selling bootleg VHS tapes of Disney cartoons. Few Mexicans see the trade as anything to be ashamed about — though the Motion Picture Association of America says piracy costs its members $300 million to $600 million a year in lost revenue in Mexico.

Today, Ortiz is Chalco’s best-known purveyor of movies and video games. She employs three clerks. “People here can’t afford to spend 100 pesos [$8] to buy these movies in a store,” said Ortiz, 39, who sells them for a dollar each.

She benefits from illegality — but pays a price.

So does Mexico.

Transparency International ranks the country a low 105 of 174 nations in its annual Corruption Perceptions Index, behind Jamaica, China, Bulgaria. The group says a motorist’s likelihood of bribing a traffic cop in Mexico state, where Chalco is located (and where Peña Nieto was governor) is more than 80 percent.

Ortiz has sold enough bootleg copies to afford a 2009 Chevy SUV and a cement-block home for her four daughters.

But on three occasions last year, Mexican federal police raided the market and confiscated thousands of dollars worth of her merchandise.

Because Mexico’s drug cartels control a major portion of the illegal DVD trade, Ortiz’s cash business in the black market has left her vulnerable.

Armed men broke into her house three years ago, she said, holding her daughter at gunpoint until she withdrew her life savings from the bank — money she had set aside for a home in a safer neighborhood.

Although the sensational violence associated with drug trafficking grabs international headlines, it is the other crime wave that most upsets Mexicans.

There were a record number of auto thefts last year: More than 85,000 cars were stolen. Robbery has increased 45 percent from 2005 to early 2012. Extortion is now the most reported crime in half of Mexico — an estimated 4.4 million attempts last year. Yet the federal census bureau found that only 12 percent of crimes are reported, because Mexicans don’t trust the police. Only 8 percent are investigated.

“My life has been difficult ever since I was kid,” Ortiz said. More bad luck followed. She received a diagnosis of cancer in the summer.

Ortiz is one of 14 million Mexicans — one-third of the labor force, and growing — who work in the informal sector.

Paid in cash and off the books, they and their employers skirt taxes and fail to enroll in government social security programs.

Ortiz has no health insurance, and she can’t afford to take time away from her DVDs. “I can’t get ahead if I don’t work,” she said, biting her lip and worrying for her daughters. “I’m the one who keeps my family together.”

No help for the little guy

A few blocks from where Ortiz hawks the latest James Bond movie, Miguel Nieves sells his elaborate cakes, decorated to celebrate birthdays and weddings.

“When I was a kid, we didn’t have enough to eat sometimes. We didn’t have our own house or a car,” Nieves said. “We never took a vacation.”

But Nieves, 38, earned an engineering degree and an MBA, then applied his business management training to his mother’s recipes. Twenty years later, he has three bakeries and 16 employees.

“Now I have a visa to go to the U.S. whenever I want,” he said. “No problems.”

Nieves said it is especially hard for small-business owners in Mexico to get ahead. He wants to open a fourth pastry shop and hire more workers, but affordable credit is impossible to come by.

His bank offered him a commercial loan at steep rates, starting at 25 percent. Credit card interest rates, plus fees, can top 50 percent.

“There’s no financing here,” Nieves said. “I have to save everything myself, and if you can’t save, you can’t grow.”

Mexican banks have more than quadrupled the amount of money available for credit since 1994, according to Bank of Mexico, and the number of credit cards in circulation has soared from 6 million to 25 million in the past decade. But economists say access to affordable credit remains one of the biggest impediments to growth.

In response, the banks — mostly foreign-owned — say Mexican courts are dysfunctional and don’t protect loan guarantees, so lenders have to charge high rates to cover defaults.

Nieves said he still has “a lot of confidence” in Mexico’s future. But he sees a business climate stacked against entrepreneurs like himself who play by the rules.

He has seen his home town transformed. But he said it is not yet a middle-class place.

“You have to be ambitious,” he said. “You can’t be satisfied with what you have. We still lack a culture that says, ‘I want more.’ ”

“The New Mexicans” series examines the dramatic demographic changes occurring in Mexico, where the middle class is becoming a majority.