BAGHDAD, Iraq — Jon Villanova had just arrived in Basra last spring to help build a police force in southern Iraq when bodies began piling up. Twenty or more Iraqi civilians were dragged from their homes, shot in the head and dumped in the streets.
The evidence pointed to some of the very people he and his team of foreign police advisers were struggling to train: a cluster of senior officers working out of a station called Jamiat.
But local officials resisted efforts to prosecute the officers. By the time officials in Baghdad intervened nine months later, the corruption in Basra had gotten so bad that the 135-member internal affairs unit, set up to police the police, was operating as a ring of extortionists, kidnappers and killers, American and Iraqi officials said.
"There we are, trying to build a police force that people can believe in, and they are committing murders," Mr. Villanova said. "It was a quagmire."
So was much of the rest of Iraq. An initial effort by American civilians to rebuild the police, slow to get started and undermanned, had become overwhelmed by corruption, political vengeance and lawlessness unleashed by the toppling of Saddam Hussein.
A year later, with the insurgency spreading with an unimagined ferocity, the United States military took charge of a second, broader campaign to reconstitute the police. On the ground, however, the military's plan for police units that could help restore order in Iraq would be no match for the forces tearing at the country in places like Basra and Baghdad. And along the way, it would help fuel some of those forces.
The Americans had to reconstitute the police since officers fled in droves after the invasion, ahead of gangs of looters. But the rush to replenish the ranks lacked proper controls, American, British and Iraqi officials said, and in the process political loyalists of the newly powerful were made officers, and there were reports of police jobs sold for kickbacks of $100.
In recent background checks, police investigators found more than 5,000 police officers with arrest records for crimes that included attacks on American troops, American officials said.
When the rebuilt skeletal force became a target of the rapidly spreading insurgency, Americans turned to heavily armed police commando units that had been assembled by the Iraqis. They added firepower, but at a price.
An Iraqi official who helped create the special units said he warned Defense Secretary Donald H. Rumsfeld that they could become a weapon in Iraq's sectarian strife, much as Mr. Hussein's police had repressed the Shiite majority. Now, after a year in which a Shiite interior minister controlled the police, some special units stand accused by many Sunnis of operating as Shiite-dominated death squads.
The Iraqis have reined in some units, but others have received less attention. In one notorious incident, a brigade in northern Baghdad is suspected of kidnapping and killing 36 Sunni Arab men last August. Although a judge ordered the unit's commander, Brig. Gen. Bassem al-Gharrawi, arrested for murder, the arrest warrant was never executed, according to court records.
Lt. Gen. David H. Petraeus, who ran the military's police training program until last September, said he backed the creation of special police units "once we saw the fighting spirit and physical toughness of the units and the competence of their leaders." But he said he also sought to impose controls and vigorously pursue allegations of misconduct.
Like the rogue police units, other government security forces are also accused of having carried out massacres and violence on behalf of political or tribal groups. Turning all of those armed forces into an effective law enforcement mechanism is a prime challenge for the new Iraqi government formed over the weekend, and is central to the American strategy for exiting Iraq.
But reforming the police means overcoming a lot of history.
Under Mr. Hussein, the police were corrupt and ill disciplined, less an instrument of law than of repression. The police became targets of the mobs of looters that roamed Baghdad after Mr. Hussein's overthrow, and then of the insurgents, who have repeatedly bombed police stations and recruiting lines. A 2006 internal police survey conducted northeast of Baghdad found that 75 percent of Iraqis did not trust the police enough to tip them off to insurgent activity.
Before the invasion, the Bush administration envisioned the police as adequate for keeping the peace and rejected a proposal backed by the Justice Department to deploy thousands of foreign police advisers.
Now the Pentagon is spreading 3,000 police trainers across the country. Maj. Gen. Joseph Peterson, who is in charge of the Pentagon's current program to remake the force, said his top priority was to improve basic skills while preventing corruption. He said the new effort was making strides toward the goal of having a force of 190,000 officers by early next year with better training and an appreciation of human rights.
"Every day the Iraqis improve their capability to do their job," General Peterson said.