When this city was among the most murderous in the world, the morgue ran out of room, the corpses stacked to the ceiling in the wheezing walk-in freezers.

Medical examiners, in plastic boots, performed a dozen autopsies a day as families of victims waited outside in numbers sufficient to require a line.

It was one of the most sensational killing sprees in recent history, with 10,500 people left dead in the streets of Juarez as two powerful drug mafias went to war. In 2010, the peak, there were at least 3,115 homicides, with many months posting more than 300 deaths, according to the newspaper El Diario. Mexico is still struggling to make sense of the bloodshed.

But the fever seems to have broken.

Last month, there were just 48 homicides — 33 by gun, seven by beatings, six by strangulation and two by knife. Of these, authorities consider 40 to be related to the drug trade or criminal rivalries.

(The Washington Post/Sources: El Diario; Chihuahua State attorney general)

Authorities attribute the decrease in killings to their own efforts: patrols by the army, arrests by police, new schools to keep young men out of gangs and in the classroom.

Yet ordinary Mexicans suspect there is another, more credible reason for the decline in extreme violence: The most-wanted drug lord in the world, Joaquin “El Chapo” Guzman, and his Sinaloa cartel have won control of the local narcotics trade and smuggling routes north.

From the beginning, Ciudad Juarez has been a key battleground in President Felipe Calderon’s U.S.-backed drug war. It was here that Calderon poured 8,000 troops and police personnel, and millions of dollars in aid, in a surge that his security experts compared to the one in Iraq in 2007.

As part of the $1.6 billion Merida Initiative, the U.S. government paid for police academies here, which included training programs for overwhelmed officers in “street survival” skills. The United States provided microscopes to the forensic lab, sent Juarez leaders to Colombia to learn how that country bested the drug cartels, helped create an anonymous tip line and supported programs for at-risk youths.

Calderon says that homicides across Mexico are decreasing, but suspicions linger because his government refuses to release nationwide data.

Juarez itself remains vulnerable. It has not escaped attention that violence began to recede after soldiers and federal police started to leave the city. Residents pray that the relative peace is maintained, while thousands of families that fled to Texas to escape the violence wonder whether it is safe to return.

At its most ferocious, when this industrial border city on the Rio Grande seemed consumed by a homicidal mania, the murder rate averaged almost nine per day.

Last month, homicides averaged 1.3 a day, the lowest rate since the war between the Sinaloa and Juarez drug cartels exploded here in 2007.

“It is a completely different ballgame now,” said Hector Murguia, the mayor. “Our city is no longer a town of ghosts.”

Families have begun to celebrate birthdays in restaurants again. At night, a few customers wander into the downtown cantinas, once a no-go zone after dark. The recession is over, and the assembly plants, which pay about $13 a day, are humming. About 20,000 jobs have been created, according to city hall.

To respond to the crisis that brought Juarez to the brink, the federal government built schools in poor barrios where there were none, as well as community centers, playgrounds and clinics. It has provided education scholarships and health insurance and given money and materiel — new pickups, bigger guns — to the municipal police, who a few years ago were not just employees of the criminal organizations but also the management.

Mexico’s interior secretary, Alejandro Poire, was recently in the city to tout Calderon’s achievements — a 50 percent reduction in the homicide rate here compared with the same period last year and a 70 percent drop compared with 2010.

“Thanks to the cooperation between federal, state and local governments, as well as public support, we are mending the social fabric,” Poire said.

Critics of the government strategy in Juarez, however, point out that the former governor of the state of Chihuahua, which includes Juarez, was himself named as a target of a federal investigation over alleged ties to organized crime, according to media accounts.

Internecine cartel war

Although often portrayed as a battle over lucrative narcotics-smuggling routes into the United States, law enforcement officials say the fight between the Sinaloa and Juarez cartels was less about feeding America’s voracious appetite for drugs and more about control of Juarez.

“From my perspective, the violence had its origin in the sale and consumption of drugs here in Ciudad Juarez; that’s what caused the bulk of the crisis,” said Cesar Peniche, the top federal prosecutor here.

By some estimates, thousands of drug distribution points and as many shooting galleries were operating in Juarez when the cartels went to war.

Some experts speculate that as it became more difficult to smuggle drugs into the United States, the mafias began paying people in product. This might have increased consumption in Juarez, where a dose of heroin sells for less than $5, the cheapest in North America.

As the federal prosecutor describes it, the cartels unleashed their armies to seize the city. At the top were leaders, such as Guzman, who probably never set foot in Juarez. The actual combatants were a handful of paramilitary-style hit squads, which included former and current police officers, and thousands of street criminals, lookouts, dope dealers and their customers, as well as impoverished teenage dropouts who were loaned a gun for a few hours.

After thousands of deaths and arrests, Mexican law enforcement officials say the Juarez cartel, Guzman’s enemy, is a shadow of its former self. A Mexican military commander said the Juarez mafia is having trouble paying its members. A Mexican state prosecutor said the organization has run out of recruits, weapons, vehicles and money.

Officials in the U.S. Drug Enforcement Administration say that both the cartels were wounded in the fight but that Guzman’s organization emerged on top.

Stoking the violence were two hyper-violent gangs called the Artistic Assassins and the Aztecas and two local leaders who pursued a strategy of mutual extermination until their capture last year.

Jose “El Diego” Acosta of the Juarez cartel was caught with intelligence from the DEA. He allegedly ordered the execution of 19 drug addicts at a halfway house. His counterpart for Sinaloa was Noel “El Flaco” Salgueiro, arrested by the military and accused in the torture-killing of the brother of the state attorney general, whose “confession” was put up on YouTube.

Unholy nexus, illegal tactics

Making matters worse, municipal police officers formed a crime collective known as the Line and worked for the Juarez cartel. A third of the local police force was fired or quit over ties to criminal organizations in 2008, the first of many ongoing attempts at housecleaning.

Federal police were notorious, too. In 2010, 250 officers mutinied against their commander in Juarez, accusing him of planting weapons and drugs on suspects to extort money.

“I don’t believe the federal police were extortionists; I know it personally,” said a Juarez construction contractor who remained in the city while 10,000 other businesses shuttered.

Human rights observers report that Mexican soldiers were themselves engaged in illegal detentions, planting evidence and torturing suspects.

“Yes, the military arrested many people, but they could not make legal cases against them. Most of those arrested were released,” said Arturo Valenzuela, a physician and leader of the We Are Juarez project, a partnership between civic groups and the government.

“The army was not very helpful,” he said.

During the peak violence, the weapon of choice was the AK-47. Attacks occurred in public places. The killings appeared timed to make the evening news broadcasts.

“I remember crime scenes where we would count 300, 400 bullet casings, from different weapons, fired by multiple shooters, with multiple victims,” said David Garcia, director of the Chihuahua State Medical and Forensic Examiner’s Office in Ciudad Juarez.

Crime scene technicians would finish their 18-hour shifts in a daze, like soldiers after combat, having seen too much.

Many assassinations — especially of police officers or prosecutors — appeared to be the work of professionals, who arrived in convoys wearing masks and body armor to scout a scene, trap the victims and assure a getaway.

This year, more homicides have been committed with smaller-caliber weapons, such as 9mm handguns. Fewer shots have been fired, and murder scenes have been less spectacular. Decapitations are no longer common. Many of the dead appear to have been killed earlier, their bodies dumped. It is rare to see a professional ambush.

Julian Leyzaola, chief of the Juarez municipal police, said the criminal groups are performing a kind of social “cleansing” by eliminating rival drug dealers, extortionists and carjackers.

In Juarez, it appears someone is mopping up.

The victims, the case backlog

Mexican law enforcement officials say that many of Juarez’s 10,500 victims appear to have been hunted down and shot.

“In other parts of Mexico, there are true clashes between the opposing groups. There are firefights, and sometimes innocent citizens are caught in the crossfire. But here in Juarez, the hit men did not confront each other directly. What the assassins did was kill each other’s low-level employees,” said Jorge Gonzalez, the Chihuahua state prosecutor in charge of the Juarez office.

El Diario reported that most of the victims appeared to be unarmed.

In Ciudad Juarez, the newspapers were filled with stories of taco vendors shot tending their stalls, of window washers executed on the street. About one in 10 of the victims was female.

Gustavo de la Rosa, a human rights advocate and researcher at the Autonomous University in Ciudad Juarez, said most of the victims — about 8,000 — were probably involved in “the great pyramid of drugs,” meaning that they were either members of gangs, sold drugs or consumed them.

De la Rosa bases his estimate on forms that his team had family members complete when it accompanied them to claim bodies. He stresses that many of the dead were low-level operatives — recruited from the estimated 14,000 young men in 800 neighborhood gangs.

Teresa Almada, director of the Center for the Promotion of Youth, suspects that the number of innocent victims is far higher and that even those who might have had some involvement in crime were so young and inexperienced as to qualify as innocent.

“They would be recruited; they would be coerced, or forced,” Almada said.

They were cannon fodder.

“Juarez is a city of orphans,” she said.

During the worst violence, many of the bodies at the morgue were unclaimed. They were buried in common graves, their assailants unknown, as case files grew into piles on the desks of prosecutors who brought no more than four cases in 100 before a judge.

The state prosecutor said he did not have the resources to pursue all the homicides. He said that based on the federal government’s definition, homicides involving “organized crime,” meaning multiple shots fired, an ambush, use of stolen vehicles, messages left at the scene — 80 percent of the killings in Juarez — should be investigated by the federal government.

“The federal prosecutor has taken less than 1 percent of the murder cases,” Gonzalez said.

The federal prosecutor conceded that his office was pursuing “very few” murder cases in Ciudad Juarez. It appeared that the number was near zero.

There have been 580 homicides in Ciudad Juarez in the first seven months of 2012, so the city is still far from its goal to be the safest in Mexico.

The criminal organizations that brought Juarez to the brink have not disappeared. “What we have seen,” said Peniche, the prosecutor, “is these groups have moved to other parts of the state.”

Gabriela Martinez in Mexico City contributed to this report.