The U.S. military handed over a $107 million prison and nearly 3,000 inmates to the Iraqi government on Monday as it prepares to leave Iraq seven years after ousting Saddam Hussein.

The formal transfer of the detention center at Camp Taji, a sprawling U.S. base north of Baghdad, is part of a plan to unwind a U.S. detention program in Iraq that cost $500 million a year at its peak.

U.S. forces had taken into custody about 90,000 people since the 2003 invasion. By August, there will only be about 100 in U.S. custody, said Major General David Quantock, head of detention operations.

At one point our guard force was over 10,000 and now we're going to go to a guard force of around 100 by the first of September, all part of the responsible drawdown plan to get U.S. forces down to 50,000, he said.

The U.S. detention centers in Iraq were being closed or transferred to the Iraqi government under a bilateral security pact signed by Iraq and the United States in 2008. The largest, Camp Bucca in the southern desert near Kuwait, was shut down last September.

The last, Camp Cropper located near Baghdad airport, will be turned over to Iraq on July 15, Quantock said.

Bucca was opened in the wake of the Abu Ghraib scandal in 2004, when shocking pictures of U.S. soldiers abusing detainees at the west Baghdad prison helped fuel a bloody insurgency.

The prison at Taji was opened in 2008 and now houses about 2,900 detainees, U.S. officials said.

Most were held under arrest warrants or detention orders from Iraq, while a few were convicted of crimes, officials said.

Under the security pact the United States is required to hand over prisoners with warrants or detention orders and release the rest.

A formal transfer ceremony was held on Monday at Camp Taji. The prison occupies just 1 square km (0.4 square mile) of the 99-sq-km (38-sq-mile) base and the U.S. military retains control of most of the base.

U.S. officials did not allow reporters to tour the facility, which Quantock valued at $107 million.

Washington plans to more than halve U.S. forces from the current 96,000 to about 50,000 by August 31, and pull almost all troops out by the end of 2011.

(Editing by Charles Dick)