The breakdown came largely in the Senate, when after a day of inaction, Republican Sen.
The House voted 240-186, with 73 Democrats and 167 Republicans voting in favor.
It is not yet clear how Congress will proceed and how public services may be affected on Friday.
Mr Trump tweeted that he had signed the bill, writing that the USA military "will now be stronger than ever before".
Democrats who voted for the budget bill, however, can tout measures scattered through the legislation such as helping dairy farmers in Vermont and more subsidized child care nationwide by ending tight budget caps on domestic spending for two years. "Also means JOBS, JOBS, JOBS!" he tweeted.
House GOP leaders Ryan, Majority Leader Kevin McCarthy and Whip Steve Scalise stood together chatting and occasionally reviewing pieces of paper but didn't appear to be engaged in an urgent operation to whip votes - suggesting confidence that the measure would pass.
House speaker Paul Ryan urged congress to avoid a "second needless shutdown in a matter of weeks - entirely needless".
Many Democrats support the budget deal, but were unhappy with the compromise because it doesn't tackle immigration - specifically addressing the plight of DREAMers, including the roughly 700,000 immigrants who are in the USA illegally after being brought to the country as children and who are enrolled in the Deferred Action for Childhood Arrivals (DACA) program, which is set to expire on March 5.
The Senate also approved the measure earlier on Friday morning.
Democrats have sought to link the funding debate to a permanent solution for the "Dreamers", who were shielded from deportation under an Obama-era program which ended last September by Trump, who set a 5 March deadline for resolving the issue.
Senate and House leaders waited Paul out, and acted as soon as their rules allowed. "The fight in the House to protect DREAMers is not over".
Ryan has said he intends to solve the problem.
The current shutdown will continue until the bill gets president trump's signature.
Jitters On Wall Street: US Stocks Turn Downward Again
Stocks can rise or fall in a single week, month, or year, but there's never been a 20-year period during which stocks lost money. Overnight yesterday in Asia, Japan's Nikkei 225 index and Hong Kong's Hang Seng fell 4.7 per cent and 4.5 per cent respectively.
But that wasn't enough to satisfy some of her base, and the leadership team sent conflicting messages, saying they weren't whipping the bill Wednesday, then sending a whip notice to vote no on Thursday. The bill McConnell chose was unrelated to immigration, after he had said he planned to use a separate bill for the debate.
But some Democrats are engaging in a high-risk, last-ditch strategy to ensure the House actually votes on immigration. Instead, they offered him a procedural vote, which Paul declined.
"We're not going to get DACA as part of this", said Rep. John Yarmuth of Kentucky, the top Democrat on the Budget Committee.
But the Freedom Caucus took an official position against the deal.
The upper chamber of Congress closed up shop late yesterday and scheduled a reopening for a new session at 12:01 am tomorrow when it will launch a new effort to pass the bill to extend government funding. Those conservatives were mainly angry about non-military spending increases. "I think it's the best deal we can get". Rand Paul. The Senate vote passed 71-28.
Without some type of funding bill, the failure to agree on a new budget means the U.S. government has technically ran out of money.
The massive budget deal, which includes a stopgap temporary measure to prevent a government shutdown, includes $300 billion for the military.
"No adversary that the United States has had anywhere on the face of the earth has done more damage to our national security than this defense sequestration that was voted by Congress".
The Senate vote, which took place just before 2 a.m., capped a topsy-turvy Thursday that featured filibuster threats, fuming congressional leaders, and frenzied vote counting.
"I can't in all good honesty and all good faith just look the other way because my party is now complicit in the deficits", he said.
"I don't know why we are basically burning time here", an exasperated Cornyn said.
Senate GOP leaders, however, were clearly irked.
Eleven Democrats and independent Bernie Sanders of Vermont also voted no.