The Iraqi parliament has voted to accept a deal on the future presence of US troops in the country.
The decision means US troops will leave Iraqi streets by mid-2009 and will quit Iraq entirely by the end of 2011.
The agreement is the result of a year of negotiations with the United States, with the Iraqis requesting several changes.
Some groups fiercely opposed the pact in parliament and at mass rallies, demanding that US troops leave earlier.
Iraq's Presidential Council must still ratify the deal but its approval is expected.
Iraq's government has hailed the parliamentary session as the prelude to the return of full sovereignty to the country.
Of the 275 members of parliament, 198 were present, with 149 voting in favour. An initial Iraqi count had put the figure at 144.
The chamber saw rowdy scenes of stamping, shouting and the waving of placards during the debate, the BBC's Humphrey Hawksley reports from Baghdad.
After last-minute negotiations that delayed the vote for a day, MPs passed it on one significant condition: that a referendum is held on the pact in the middle of next year.
If that fails to endorse the withdrawal plan, the BBC reports US troops may have to leave earlier, possibly by the middle of 2010.
Minority Sunni MPs failed to win concessions on the disbanding of a special tribunal dealing with crimes committed when Saddam Hussein was in power and laws over former members of Saddam's Baath party, who were almost all Sunnis.
In a statement from Washington, President George Bush congratulated the Iraqi parliament, saying its vote had affirmed "the growth of Iraq's democracy and increasing ability to secure itself".
Earlier, US Ambassador to Baghdad Ryan Crocker and General Ray Odierno, the top commander of US troops in Iraq, said a joint statement that the vote would "formalise a strong and equal partnership".
Under the deal, all 150,000 US troops have to leave Iraq by the end of 2011.
The agreement was necessary as a UN mandate on the role of US military forces in Iraq, expires on 31 December of this year.