BAGHDAD - For years, extremist Iraqi detainees in U.S. custody held self-styled Islamic courts and tortured or killed inmates who refused to join them, military officials said, disclosing new details about the use of American prisons to recruit for the insurgency.

The problem became the main catalyst for a decision to separate moderate detainees from the extremists, part of a reform package aimed at correcting widespread U.S. prison abuses that sparked international criticism.

"We were having people who weren't insurgents who were being forced to be insurgents because of the power of these courts, the power of al-Qaida and other extremist groups," said Lt. Col. Kenneth Plowman, a spokesman for Task Force 134, which operates coalition detention facilities in Iraq.

He told the Associated Press that the jailhouse Shariah courts were formed, despite the presence of U.S guards, to enforce an extreme interpretation of Islamic law. They were then used to convict moderate inmates, who were then tortured or killed, he said.

In comments published in The Herald in Sierra Vista, Ariz., Brig. Gen. Rodney L. Johnson, commander of the U.S. Army Criminal Investigation Command, put the number of detainees tried by the courts in the double digits. Neither he nor Plowman would give specific numbers.

The courts were eradicated, and none have been detected in six months although some gang-related issues persist, Plowman said. "We have a detainee population of about 21,000," he added. "You're gonna have extremists who will find a way to communicate and to form these kind of organizations." But he said guards had stepped up to block efforts to form new courts.

The classification of detainees into moderate and extremist groups was part of sweeping reforms launched by the former commander of detainee operations, Maj. Gen. Douglas Stone, in a bid to overcome a series of scandals over the treatment of detainees in U.S. custody.

It was also in line with a new counterinsurgency strategy by the Americans that focused on isolating the general population from the militants to stem support for the fighting.

"The problem's been apparent, and when Stone took command, that was one of his first initiatives - to separate out the detainees into categories like moderate, extremists, etc., in order to resolve this issue," Plowman said. "There hasn't been any real Shariah court for six months or so."

The overall number of detainees has fallen from a peak of 26,000 last summer to just over 21,000, according to officials.