WASHINGTON (Reuters) - The U.S. Congress is set to debate legislation that would extend until May 5 the deadline for a deal on federal spending through September and head off a feared government shutdown at midnight on Friday.

FILE PHOTO: U.S. President Donald Trump's overview of the budget priorities for Fiscal Year 2018 are displayed at the U.S. Government Publishing Office (GPO) on its release by the Office of Management and Budget (OMB) in Washington, U.S. on March 16, 2017. REUTERS/Joshua Roberts/File Photo

The House Rules Committee, in a late-night meeting, voted 8-2 to send the legislation to the full House of Representatives for debate and votes on passage on Friday, just hours before expiry of a deadline for funding many federal agencies.

If the measure passes the House, as expected, the Senate would be prepared to promptly take up the bill, in the hope of also passing it and sending it to President Donald Trump to be signed into law.

The measure would give Republican and Democratic lawmakers an additional week to work out differences on about $1 trillion in funding for the government through Sept. 30, the end of the current fiscal year.

Without the extension or a longer-term funding bill, federal agencies will run out of money by midnight Friday, likely triggering abrupt layoffs of hundreds of thousands of federal government workers until funding resumes.

The last government shutdown, in 2013, lasted for 17 days, and many lawmakers were nervous about the prospect of another.

“I’m confident we will be able to pass a short-term extension” of funding for programs for the fiscal year that began nearly seven months ago, House Speaker Paul Ryan told reporters early on Thursday.

House Democratic leader Nancy Pelosi warned that the purpose of the stopgap measure was to tie up loose ends of a deal to provide around $1 trillion in money for the fiscal year ending Sept. 30 and not for “kicking the can down the road to have this same back-and-forth” over funding disputes.

House Appropriations Committee Chairman Rodney Frelinghuysen expressed optimism in a statement that a final funding package will be completed soon.

In the midst of the delicate negotiations, Trump took to social network Twitter to blast Democrats.

“As families prepare for summer vacations in our National Parks - Democrats threaten to close them and shut down the government. Terrible!” Trump tweeted in a series of tweets.

Negotiators were racing against the clock to resolve remaining disputes in the massive spending bill amid talks that have already handed Democrats at least two major victories, despite Republican control of Congress.

Trump, a Republican, gave in to Democratic demands that the spending bill not include money to start building the wall he wants to erect on the U.S.-Mexico border. His administration also agreed to continue funding for a major component of Obamacare, formally known as the Affordable Care Act, despite vows to end the program.

It remained unclear whether Republicans would prevail in their effort to sharply hike defense spending without similar increases for other domestic programs. Trump has proposed a $30-billion spending boost for the Pentagon for the rest of this fiscal year.

Such funding disputes could resurface later in spending bills for the next fiscal year.

Disagreements remaining to be ironed out include funding to make a healthcare program for coal miners permanent and to plug a gap in Puerto Rico’s Medicaid program, the government health insurance program for the poor.