After a long night of tense negotiations, lawmakers finally came to an agreement over a budget that will keep the government running through the end of the fiscal year. The deal, which was reached shortly before the midnight deadline, featured concessions from both sides, with Democrats agreeing to about $38 billion in spending cuts, while Republicans dropped policy riders regarding limiting environmental regulations and funding for Planned Parenthood. Both the House and Senate voted to approve a stopgap to keep the government running until next Thursday, by which time a bill will be presented to President Obama for his approval.

“Today, Americans of different beliefs came together,” Obama said in a statement from the White House. “We protected the investments we need to win the future.”

While some of the framework for the agreement was in place as early as Friday morning, Democrats and Republicans spent the day waging a very public fight over the final points of the agreement, both seeking to heap blame on the other in the event of a shutdown. While money remained an important issue, the riders attached to any potential agreement by Republicans became a particular sticking point. In the end the most controversial riders regarding limiting environmental protections and funding for Planned Parenthood were abandoned, although the agreement includes language that prohibits public money from being used towards abortions in Washington D.C.

While neither side got exactly what they wanted, and neither will come out spotless in the public eye, there was relief over having finally reached an agreement. “I’m pleased that Senator Reid and I and the White House have been able to come to an agreement that will, in fact, cut spending and keep our government open,” Speaker John Boehner said in a statement.  “We didn’t do it at this late hour for drama,” said Democratic majority leader Harry Reid in another. “We did it because it has been hard to arrive at this point.”