When authorities decided to clean up this town, they didn't take any chances. Police swooped in just before midnight, armed with riot gear and backhoes. The invaders were repelled, the streets reduced to rubble.

A sneak attack to eradicate drug dealers? Gang members? Armed insurgents?

No, municipal leaders were uprooting sidewalk vendors, mostly women and senior citizens, whose makeshift taco stands and clothing stalls were clogging the city center. Ordered to relocate to make way for an urban renewal project, most had refused to budge, leading authorities to eject nearly 1,900 by force.

"The mayor wants to create a tidy First World city in this place where people have nothing," said Jose Luis Vargas, the leader of a group of vendors protesting their ouster in late March. "Better to die fighting than to die of hunger."

The dust-up in this gritty municipality northeast of the capital underscores a turf battle being waged throughout Mexico.

More than a decade after the landmark North American Free Trade Agreement transformed Mexico into an exporting powerhouse, the nation's formal economy of on-the-books businesses and workers who pay taxes is dramatically losing ground to the underground sector.

From 2000 to 2004, the underground economy was Mexico's sole source of employment growth, and it's growing. Some economists estimate that as many as half the nation's workers eke out a living in subsistence jobs because there is nothing for them in the legitimate economy and no safety net for the jobless.

The underground sector provides cheap goods and services for millions of low-income people, while giving Mexico an official jobless rate lower than that of the United States. Andres Manuel Lopez Obrador, the mayor of Mexico City and a 2006 presidential hopeful, credits that entrepreneurial grit for easing tensions in a nation whose formal sector is creating far fewer than the 1 million jobs a year needed just to keep pace with population growth.

"Why hasn't there been a social explosion in Mexico?" he wrote in his recent book outlining his vision for fixing Mexico's employment and development woes. "The escape valve has been the informal economy, migration and drug trafficking. It's painful to admit it, but that's the reality."

Business leaders complain that entire industries are being lost to pirates and off-the-books entrepreneurs. Tax revenue is dropping. And Mexico's urban areas are feeling the heat from the explosion of ambulant vendors, pitting residents' quality of life against the peddlers' need to scratch out a living.

The friction is most evident in Mexico City, the capital, where an estimated 500,000 itinerant vendors ply their trade, hawking phone cards at traffic lights, bootleg CDs in the subway and snacks from kitchens set up on sidewalks.

The area surrounding the Zocalo, the sprawling central square that is the symbolic heart of Mexico, resembles a giant swap meet. Parts of stately Chapultepec Park looked like a county fair until last fall, when management closed a popular section for maintenance. Officials in swanky Polanco, Mexico City's Beverly Hills, are trying to relocate nearly 500 itinerant merchants who sell food and trinkets not far from high-end shops.

"It's out of control," said Fernando Aboitiz, a Mexico City legislator whose district includes Polanco. He said the government had been forced to negotiate with ambulant vendors rather than simply evict them.

That's because Mexico's underground economy is so mammoth that informal-sector workers such as street vendors and unlicensed cabdrivers have formed unions to protect their territory. Although Mexican cities have zoning ordinances, the reality is that possession is nine-tenths of law. Once established, open-air merchants are extremely difficult to dislodge. They alternately pay off authorities or take them on with marches, sit-ins and blockades.

What looks chaotic to the casual observer is actually a highly organized industry. Most vendors in the capital pay dues of a few dollars a day to their leaders, who divvy up territories and keep the peace with government officials and competitors. They don't always succeed. Alejandra Barrios, leader of one of Mexico City's biggest peddler groups, is in prison awaiting trial after a rumble with another union over turf. The 64-year-old is accused of organizing the 2003 shooting death of the husband of a rival leader with whom she had been feuding.

But vendors scoff at the notion that they are criminals or the nexus of Mexico's employment troubles.

Elizabeth Tapia Alonso, a single mother, supports her three children selling men's clothing on the streets of Tlalnepantla. She can't count on the government, a boss or family to bail her out when the children are sick or the electric bill is due.

"It's all up to me," she said. "There aren't any jobs, and even if there were, no one would hire someone like me, with no education."

In the first four years of President Vicente Fox's term, which began in 2000, Mexico did not create a single net new position in its formal economy -- the universe of legally registered businesses that pay employment taxes and enroll workers in the social security system.

In contrast, off-the-books employment surged, fueled largely by street vendors, whose ranks ballooned by 40 percent from 2000 to 2003 to more than 1.6 million. In all, the Mexican government estimates that slightly more than 11 million Mexicans, or about one-quarter of the workforce, toil in the underground economy. Some academics and economists here say half Mexico's workforce is informal.

That shadow activity is weighing heavily on Mexico's development. Few in the informal sector pay business or income taxes. It is one of the reasons that Mexico, one of the world's 15 largest economies, ranks with the likes of Sri Lanka when it comes to collecting revenue to pay for education, infrastructure and basic public services. That is hurting its global competitiveness.

Analysts are split on what's driving the trend. Advocates of free-market economics say countries such as Mexico haven't gone far enough in opening and reforming their economies even though trade barriers have fallen throughout the hemisphere. Critics of globalization, however, blame trade pacts that have walloped farming regions in poor countries, sending millions of rural dwellers to the cities to find work.

All Maria de los Angeles Vanegas knows is that there are too many vendors crowding the streets of Chalco, a working-class community of 250,000 residents about 30 miles southeast of Mexico City.

The head of a neighborhood group called Let's Save Chalco, Vanegas is pushing municipal officials to rein in the Friday market that attracts 5,000 vendors to a 10-square-block area of the city center. She said what started decades, perhaps centuries, ago as a weekly opportunity for indigenous farmers to sell their produce has become a free-for-all of cheap Chinese imports and stolen merchandise sold by vendors who don't live in the community.

Wending her way through the stalls of faux Nike sneakers and sizzling pork tacos on a recent Friday, she pointed to dozens of the electrical cords, known as little devils, that street merchants use to swipe electricity from nearby poles. Traffic crawled. Drivers cursed and honked. Vendors' boomboxes blared. The resulting garbage is so thick that locals say wild dogs come in from the countryside every Friday night to feast.

"We are prisoners in our own community," an exasperated Vanegas said.

But the vendors feel helpless in Tlalnepantla, where authorities forcibly ejected sidewalk merchants who refused to leave their spaces in the city center. Peddlers said they received no warning of the raid, an allegation authorities dispute. What's clear is that hundreds of police officers secured the area while heavy-equipment operators destroyed the metal stalls that some vendors had anchored to the sidewalks. They then tore up the pavement.

"All we want is a city that is cleaner, more secure, more attractive and a better place to live," Tlalnepantla's mayor, Ulises Ramirez Nunez, said of the redevelopment project.

Some of the vendors, many of them elderly women, wept openly amid the rubble.

Patrocinea Santiago, 73, earned a few dollars a day selling fruits and vegetables.

"At this age, where else can I go?" she said, her eyes brimming with tears.

But just beyond the perimeter of destruction, other street entrepreneurs were already throwing down tarps loaded with merchandise onto the sidewalks, keeping their eyes peeled for police.

"We have to work," said a wary young man selling socks. "We have to eat."

Customers look at street-market goods for sale in Mexico City, which has an estimated 500,000 itinerant merchants.