U.S. President George W. Bush, who arrived in Baghdad on an surprise visit on Sunday, signed with Iraqi Prime Minister Nouri al-Maliki a security pact which outlines a timetable for the U.S. troops' withdrawal in three years, the Voices of Iraq news agency reported.
The document, known in Iraq as the U.S. troops withdrawal agreement, was passed at the Iraqi parliament last month.
Under the plan, the U.S. troops will pull out of Iraqi cities and towns by the end of June next year and withdraw from Iraq by 2012. Iraq also put restrictions on the U.S. military operations and conditionally gained jurisdiction on American troops.
Bush has strongly opposed a firm withdrawal timetable.
The top U.S. commander in Iraq Gen. Ray Odierno said Saturday part of American troops will continue to stay in cities after the summer of next year to train the Iraqi security force.
Earlier on Sunday, Bush met Iraqi President Jalal Talabani and acknowledged that the war has been hard.
"The work hasn't been easy but it's been necessary for American security, Iraqi hope and world peace," according to a statement by Talabani's office.
Talabani said Bush is "a great friend" of the Iraqi people. The two leaders discussed how to push forward bilateral relations.
This was Bush's fourth visit here and very likely the last before he leaves office in January.
The United States has spent over 600 billion U.S. dollars on the war and lost more than 4,200 soldiers.
The unpopular war has badly hit Bush's approval ratings. In an interview with the ABC TV station early this month, Bush acknowledged that the" biggest regret" of his presidency was the intelligence failure in Iraq.
The U.S. waged the war on the grounds that Saddam Hussein possessed weapons of mass destruction, which have not been found.