Ending weeks of infighting, the U.S. Congress on Wednesday voted to avert a government shutdown just hours before a midnight deadline, passing a stop-gap measure to extend funding for federal agencies until Dec. 11.
The House of Representatives relied heavily on Democrats to secure passage in a 277-151 vote. A large majority of Republicans voted against the measure, which did not meet conservatives' demands to cut off money to women's healthcare provider Planned Parenthood amid an abortion controversy.
The House also passed a companion bill aimed at restoring the Planned Parenthood defunding provision, but the Senate is not expected to act on it, effectively killing it.
President Barack Obama signed the spending extension into law later on Wednesday, the White House said in a statement.
Obama welcomed the news with a tinge of sarcasm in remarks to a group of progressive state legislators in Washington.
"The good news is that it looks like the Republicans will just barely avoid shutting down the government for the second time in two years. That's a somewhat low bar but we should celebrate where we can," Obama said.
"The bad news is that it looks like Republicans will just barely avoid shutting down the government again for the second time in two years," he added.
Earlier in the day, by a vote of 78-20, the Senate approved the legislation that was needed to keep the government running at current levels with the start of the new fiscal year on Thursday.
The controversy over Planned Parenthood funding threatened a repeat of a 17-day shutdown in October 2013 that was prompted by Republican demands to deny federal funding for Obama's healthcare law, the Affordable Care Act.
House conservatives, cheered on by some Senate colleagues, had insisted that Planned Parenthood be punished for allegedly improperly selling fetal tissue harvested from abortions. The organization has denied the allegations.
The debate shifted dramatically last week when House Speaker John Boehner announced his resignation and said he would put the Senate's "clean" funding bill to a vote.
The funding extension aims to give congressional negotiators and Obama about 10 weeks to work out a longer-term budget deal and ease automatic spending constraints on military and domestic spending. Senate Majority Leader Mitch McConnell has said he would like to reach a deal with Democrats that sets funding levels for two fiscal years, through Sept. 30, 2017.