The Senate on Thursday overwhelmingly passed a bill that would fund the federal government through the end of September, sending the measure on to President Obama for his signature.

The deal to cut $38.5 billion in spending, which was announced late last week after lengthy wrangling between the White House and congressional leaders, passed the Senate on Thursday 81 to 19, hours after the House passed it on a 260-to-167 vote.

President Obama must sign the funding measure into law by midnight Friday in order to avert a federal shutdown. The bill’s passage caps off a tumultuous several months of wrangling between members of both parties on how to keep the government funded. Both chambers passed eight stopgap bills this fiscal year to keep the government running, with the latest one signed into law by Obama late last week.

Voting no on the funding bill were four Democrats and 15 Republicans. They were: Sens. Tom Coburn (R-Okla.), Mike Crapo (R-Idaho), Jim DeMint (R-S.C.), John Ensign (R-Nev.), Lindsey Graham (R-S.C.), Orrin Hatch (R-Utah), James Inhofe (R-Okla.), Ron Johnson (R-Wis.), Patrick Leahy (D-Vt.), Mike Lee (R-Utah), Carl Levin (D-Mich.), Rand Paul (R-Ky.), Jim Risch (R-Idaho), Marco Rubio (R-Fla.), Bernie Sanders (I-Vt.), Richard Shelby (R-Ala.), Pat Toomey (R-Pa.), David Vitter (R-Nev.) and Ron Wyden (D-Ore.).

The Senate also on Thursday rejected measures that would have stripped federal dollars from the national health-care law and from Planned Parenthood; holding the two votes was a condition of the budget deal.

The health care defunding bill failed the Senate on a straight party-line vote, 47-to-53. It had earlier passed the House on a 240-to-185 vote, with three Democrats joining all Republicans to support it.

The bill to defund Planned Parenthood failed on a 42-to-58 vote, with five moderate Republicans – Sens. Scott Brown (Mass.), Susan Collins (Maine), Olympia Snowe (Maine), Mark Kirk (Ill.) and Lisa Murkowski (Alaska) – joining all 53 members of the Democratic caucus to oppose the measure. The measure passed the House earlier Thursday on a 241-to-185 vote; seven House Republicans joined most Democrats in opposing it, while ten Democrats bucked their party to support the measure.

Even as Congress wrapped up its work on the budget for the 2011 fiscal year, House lawmakers were beginning debate on the fiscal year 2012 budget proposed by Rep. Paul Ryan (R-Wis.). A vote on the measure, along with several alternative budgets, is expected Friday.