Iraq also obtained a significant degree of jurisdiction in some cases over serious crimes committed by Americans who are off duty and not on bases.

In Washington, the White House welcomed the vote as “an important and positive step” and attributed the agreement itself to security improvements in the past year.

Throughout the negotiations, the Shiite parties and the prime minister, Nuri Kamal al-Maliki, under pressure from forces both within and outside the country, had been trying to strike a balance in forging a viable agreement with the Americans that would guarantee Iraq’s security and that would still stand firm against what many, including neighboring Iran, consider a hostile force that has occupied Iraq since the spring 2003 invasion that toppled Saddam Hussein.

“This vote shows that the Iraqis have figured out how to stand up for themselves, to Iran and to the U.S.,” said Michael E. O’Hanlon, a specialist on Iraq at the Brookings Institution. “They will have stared in the face at the various options and concluded that none are ideal, but the best for their security is an amount of ongoing but finite American cooperation, while also indicating their strong desire to run their own country on their own as soon as possible.”

Image Iraqi policemen danced with a United States Army soldier in Baghdad on Sunday, the day Iraqs cabinet approved a security pact. Credit... Karim Kadim/Associated Press

American officials said the accord was the result of tough bargaining by the Iraqis. Speaking about the negotiations a few days before the cabinet vote, Ryan C. Crocker, the American ambassador, said of the 100 requests for changes sought by the Iraqi side in recent weeks: “Some were substantive, some were linguistic, some were stylistic. We looked at it all; we were as forthcoming as we could possibly be in responding.” Some Iraqi Shiite politicians said a significant factor in the cabinet decision was the approval of the pact by Grand Ayatollah Ali al-Sistani, the most influential Shiite cleric in Iraq, who from the outset had laid down three conditions: full Iraqi sovereignty, transparency and majority support for the pact.