US President George W. Bush, who arrived in Baghdad on a surprise visit on Sunday, signed with Iraqi Prime Minister Nouri al-Maliki a security pact which outlines a timetable for the US troops' withdrawal in three years, the Voices of Iraq news agency reported.
The document, known in Iraq as the US troops withdrawal agreement, was passed at the Iraqi Parliament last month.
Under the plan, the US troops would 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 US military operations and conditionally gained jurisdiction on American troops.
President Bush has strongly opposed a firm withdrawal timetable.
The top US commander in Iraq General Ray Odierno said on Saturday part of American troops would continue to stay in cities after the summer of next year to train the Iraqi security force.
Earlier on Sunday, President 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 President Talabani's office.
President Talabani said President Bush was "a great friend" of the Iraqi people. The two leaders discussed how to push forward bilateral relations.
This was President Bush's fourth visit in Baghdad and very likely the last before he leaves office in January.
The United States has spent over 600 billion dollars on the war and lost more than 4,200 soldiers.
The unpopular war has badly hit President Bush's approval ratings. In an interview with the ABC TV station early this month, President Bush acknowledged that the" biggest regret" of his presidency was the intelligence failure in Iraq.
The US waged the war on the grounds that Saddam Hussein possessed weapons of mass destruction, which have not been found.