UPDATE, 8:45 p.m. EDT: President Barack Obama has signed into law a bill that avoids a government shutdown and provides Congress and the president more time to draft a longer-range budget agreement, Associated Press reported.

The House and Senate each approved the bill earlier in the day. The legislation provides financing for the government through Dec. 11, providing time to negotiate a deal that would be in effect beyond the 2016 presidential election.

Original story:

The U.S. Congress narrowly avoided a government shutdown Wednesday when it passed legislation that will fund federal agencies until Dec. 11, the Associated Press reported. The stopgap funding bill, which the House of Representatives passed along to be signed into law by President Barack Obama, aims to give congressional negotiators and the president roughly 10 weeks to establish a longer-term budget deal that would last through the new fiscal year, which ends Sept. 30, 2016.

With a vote of 277-151, the House approved the legislation with just hours to spare before the midnight deadline. Earlier Wednesday, the Senate approved the legislation 78-20. The funding bill, which is known as a continuing resolution (CR), was essential in avoiding a government shutdown, Reuters reported.

"This CR, while not ideal, is the next step towards that end, keeping the government's lights on as we work to find a solution," House Appropriations Committee Chairman Hal Rogers said in a House debate, Reuters reported. "With current funding set to expire in just hours from now, I urge my colleagues to do the responsible and reasonable thing and support this continuing resolution today."

GettyImages-490557538 U.S. Senate Majority Leader Sen. Mitch McConnell (left) and Senate Majority Whip Sen. John Cornyn at a media briefing after the weekly Senate Republican Policy Luncheon at the U.S. Capitol in Washington, Sept. 29, 2015. Photo: Getty Images

For weeks, conservatives in the House of Representatives have demanded the defunding of healthcare provider Planned Parenthood and even threatened a government shutdown. The House ended up approving the bill, which was stripped of the tea party-backed measure that would have taken away federal funding from Planned Parenthood. However, bowing to conservative demands, the House is also set to pass a separate piece of legislation that would defund Planned Parenthood, but that measure is not expected to advance in the Senate. 

"You want to understand the volcanic frustration with Washington? It's that the Republican leadership in both houses will not fight for a single priority that we promised the voters we would fight for when we were campaigning less than a year ago," Florida Sen. Ted Cruz, a GOP candidate, said Monday, the Associated Press reported.