The bill gives funding for the conflicts through to mid-2009 after President George W. Bush, who must now sign the bill into law, has left office.
The legislation passed 92 votes to six in the Senate after its approval by the House of Representatives June 19 topped weeks of haggling between Democrats and Republicans.
Bush has indicated he will sign the legislation despite opposing some of the measures included in it.
The deal was reached after Democrats agreed to drop a withdrawal timetable from the bill. The majority party has repeatedly failed to force Bush's hand on Iraq since taking over Congress in 2006 elections.
Democrats insisted on inserting a modern version of the post-World War II GI Bill in order to expand education benefits to veterans, a plan that Senate Republicans and the White House had opposed.
The House passed the war funding section of the bill by a 268-155 vote, with only 80 Democrats voting in favor along with 188 Republicans.
The veterans' benefits part of the legislation, which also included a 13-week extension of unemployment benefits and aid for Midwest flood victims, was overwhelmingly approved, 416 to 12.
The legislation calls on the Iraqi government to spend as much money as US taxpayers for reconstruction and bars the Bush administration from using the funding to establish permanent bases in Iraq.
Democratic Senator Robert Byrd noted that with this new funding, Congress will have approved over 656 billion dollars for the war in Iraq.
But he expressed frustration that Bush repeatedly threatened to veto the measure unless a troops withdrawal timetable was removed.
"Despite the positive measures for struggling Americans, our veterans, and their families included in this amendment, I deeply regret that this legislation will go to President Bush without the necessary checks to ensure that the war in Iraq is not open-ended," Byrd said in a statement to the Senate.
"The majority of the American people have come to see this war as a costly mistake that needs to be brought to a close. This legislation brings us no closer to that goal.
"However, with this legislation, we will once again take care of our troops. We also invest in America here at home."
Republican White House hopeful John McCain, a staunch backer of the war in Iraq, hailed the bill last week when it passed the House, while his Democratic rival Barack Obama has vowed to withdraw troops from Iraq.
"This bill is about giving the men and women of our military the same education benefits that all of America's veterans have received since World War II," said Republican Senator Chuck Hagel, who cosponsored the bill's post 9/11 Veterans Assistance Act with Virginia Democrat Jim Webb.
"In rotating forward these earned benefits into the 21st century, making them relevant to the realities of the cost of education today, we are fulfilling a commitment that we have all made to our veterans," he added.
"By investing in education we are investing in America's future and continuing to build a society worthy of the sacrifices of our veterans. ... This was the ri
© 2008 Agence France Presse