Democrats and Republicans narrowly averted a partial shutdown of the federal government Friday night, agreeing on a budget deal and a short-term funding extension little more than an hour before the clock struck midnight and time ran out.

The new funding extension, which cuts spending by $2 billion, will last through next Thursday.

"The government will be open for business," President Barack Obama said.

"In the final hours before our government would have been forced to shut down, leaders in both parties reached an agreement that will allow our small businesses to get the loans they need, our families to get the mortgages they applied for, and hundreds of thousands of Americans to show up at work and take home their paychecks on time."

Negotiators capped days of frantic closed-door talks and public recriminations by agreeing on a framework for a package of $38.5 billion in spending cuts covering the rest of the fiscal year, which expires September 30.

Republicans, bolstered by their capture of the House of Representatives in last November's midterm elections, had initially pushed for $61 billion in cuts.