US troops - like this one dancing with Iraqi police - are to leave by 2011
The Iraqi cabinet has approved a security pact with the US governing the future presence of 150,000 US troops in the country, officials have said.
Under the deal, US troops will withdraw from the streets of Iraqi towns next year, leaving Iraq by the end of 2011.
The decision will need to go before Iraq's parliament for a final vote.
America's National Security Council welcomed the cabinet's vote, saying it was "an important and positive step" towards stability and security.
The pact is necessary to determine the role of US military forces in Iraq after their UN mandate expires on 31 December 2008.
In October, Iraq sent a new round of suggested changes to the draft Status of Forces Agreement (Sofa), to which the US responded.
Washington had previously said the pact was "final" and could not be amended.
The UK government, which has 4,100 troops in Iraq, is waiting for the US-Iraqi pact to be approved so they can use it as a template for their own bi-lateral deal.
As the Iraqi cabinet met on Sunday, two bomb attacks - in Baghdad and Diyala province - killed at least 18 people and wounded many more.
The cabinet approved the pact after a two-and-a-half hour meeting
The cabinet approved the pact after a two-and-a-half hour meeting, government spokesman Ali Dabbagh said.
All but one of the 28 ministers present had voted in favour of the pact, he added, according to the Associated Press news agency.
According to Mr Dabbagh, the agreement's terms include:
- placing US forces in Iraq under the authority of the Iraqi government
- US forces to leave the streets of Iraq's towns and villages by the middle of 2009
- US forces to hand over their bases to Iraq during the course of 2009
- US forces to lose the authority to raid Iraqi homes without an order from an Iraqi judge and permission of the government.
In a statement, US National Security Council spokesman Gordon Johndroe said the US hoped for a successful vote in the Iraqi parliament:
"We remain hopeful and confident we'll soon have an agreement that serves both the people of Iraq and the United States well and sends a signal to the region and the world that both our governments are committed to a stable, secure and democratic Iraq."
The BBC's Andrew North, in Baghdad, says that a compromise was reached on the key issue of Iraqi jurisdiction over US troops and contractors in the country.
In it, a joint committee will decide if Americans who commit crimes outside US bases should face Iraqi justice.
While many Iraqi politicians publicly oppose the deal, our correspondent says, in private they support it.
They believe it will give the government more power over US troops and will allow the Iraqi military more time to develop into an effective security force.
The agreement is set to be submitted to Iraq's parliament later on Sunday, but it is not clear when the body will vote on it.
It then needs to be ratified by Iraq's presidential council before Prime Minister Nouri Maliki can sign the deal with US President George W Bush.
The BBC's Bob Trevelyan says that Mr Maliki has been trying to build support for the amended pact and the main Shia and Kurdish alliances in parliament have recently agreed to back it.
He also appears to have persuaded the country's most senior Shia cleric, Grand Ayatollah Ali al-Sistani, not to oppose it publicly.
The cleric is highly influential in Iraq's Shia community. Any public criticism of the pact by him would probably have stopped it winning parliamentary approval, our correspondent says.
Iraqi officials say failure to pass the agreement would be highly damaging for Iraqi security.
US officials have said it would mean suspending their operations in Iraq.
Speaking before Sunday's meeting, Iraq's lead negotiator, Muwafaq al-Rubaie, said he believed the draft agreement was a "very good text" and he expected it to be approved by parliament as well.
But the pact has drawn fire from hardline nationalists, especially Iraq's influential Shia cleric, Moqtada Sadr, whose supporters have called for mass demonstrations to oppose any agreement with the US "occupier".
On the streets of Baghdad there was a mixed reaction to the pact.
''We don't want an agreement with America," said Rasheed al-Jumali.
"We don't want an agreement with Israel. We don't want an agreement with Iran. They (the government) should work towards reinforcing the gallant Iraqi army. We fully and totally reject this security pact.''
But Mun'am al-Abadi backed the government, adding: "The Iraqi government knows its people well. We are oppressed people. If the security agreement benefits us, we accept it completely.''