The U.S. military said Saturday it has released more than 10,000 detainees in Iraq so far this year — more than in all of 2007 — as it continues to try phase out its running of Iraqi prisons.

The military said about 21,000 people remained in custody, and it is currently releasing about 45 detainees and detaining 30 a day.

The United States wants to transfer the detainees to Iraqi control. Reaching that goal has been slowed partly by the lack of adequate Iraqi prison space and trained guards. More than 8,900 people were released from detention last year.

The U.S. military separated moderate detainees from extremists and instituted religious, educational and vocational programs over the past year to try to rehabilitate less dangerous prisoners. It also increased releases under amnesty programs.

"Due to changes in the conduct of detainee operations and programs to prepare detainees for reintegration into society, we have not only gone over 10,000 releases, but our re-internment rate is less than 1 percent," said Gen. David Petraeus, the top U.S. commander in Iraq.

The U.S. military says its detention system is authorized by a U.N. resolution under which the Iraqi government allows U.S. troops to arrest people at will. U.S. military attorneys say it also complies with international laws covering warfare and was created in "the spirit" of the Geneva Conventions.

Commanders say they are entitled to hold any prisoner until the detainee is no longer considered a threat to U.S. forces. Local law and court rulings do not apply, they add.

Rights groups have criticized U.S. detention policy as a misrepresentation of international law, which they say requires some form of legal process to detain someone.

The right of the U.S. to detain Iraqi citizens has been one of the contentious areas of debate with the Iraqis over a new security agreement that would keep U.S. forces in the country after a U.N. mandate expires at year's end.

Many Iraqi officials want the country's courts to have sole responsibility for arresting and detaining Iraqi citizens.

The average detention time is 330 days, the military said on Saturday. About 17,000 of the inmates, including some of the most dangerous, are held at Camp Bucca — a facility in southern Iraq.

The military has increased control over prisons to correct widespread U.S. prison abuses that sparked international criticism.

Allegations of abuse at U.S. prisons escalated in 2004 with the release of pictures of grinning U.S. soldiers posing with detainees at the Abu Ghraib facility west of Baghdad. Some were naked, being held on leashes or in painful and sexually humiliating positions.

That prison has since been closed, and 11 U.S. soldiers were convicted of breaking military laws. Five others were disciplined in the scandal.