The Senate on Thursday afternoon approved a border security package to avert another government shutdown, as the White House said President Trump is preparing to take the extraordinary step of declaring a national emergency to obtain additional funding for his long-proposed wall on the U.S.-Mexico border.

The bill passed 83-16. The border security compromise now heads to the House for a vote.

On Thursday night, the House approved the proposal 300-128.

WHAT IS A 'NATIONAL EMERGENCY,' AND HOW CAN TRUMP USE IT TO FUND BORDER WALL?

Before the Senate vote, White House press secretary Sarah Sanders said the president would sign the compromise bill, and would take executive action to unlock other federal dollars for the wall.

“President Trump will sign the government funding bill, and as he has stated before, he will also take other executive action -- including a national emergency -- to ensure we stop the national security and humanitarian crisis at the border," Sanders said in a statement. "The president is once again delivering on his promise to build the wall, protect the border, and secure our great country.”

The president is expected to sign the bill at 10 a.m. Friday, Fox News has learned.

Lawmakers have until 11:59 p.m. Friday to get the agreement through both houses of Congress and signed by Trump before several Cabinet-level departments shut down and hundreds of thousands of federal workers are furloughed in what would be the second partial government shutdown this year.

Sanders told reporters at the White House there will be an announcement later about where the money will come from and how they allocate it. She said the White House is working on those details.

Asked if they were afraid of legal challenges, Sarah said, “We are very prepared but there shouldn’t be. The president is doing his job and Congress should do theirs.”

Speaking on the Senate floor earlier, Senate Majority Leader Mitch McConnell said he supports Trump declaring a national emergency to fund the border wall, something the president has suggested for weeks he might do.

BORDER COMPROMISE: TRUMP'S REPORTED PLAN TO SIGN BIPARTISAN DEAL GETS MIXED REVIEWS

But Democrats in Congress said they hoped Trump wouldn't declare an emergency.

"It’s a terrible idea," Delaware Sen. Chris Coons told Fox News. "We will all live to regret this one.”

House Speaker Nancy Pelosi, D-Calif., told reporters Democrats "are reviewing our options."

There are at least 30 national emergencies in effect in the United States as of this month, according to a tabulation prepared by the Congressional Research Service.

The product of nearly three weeks of talks, the border security agreement would provide almost $1.4 billion for new barriers along the boundary. That's less than the $1.6 billion for border security in a bipartisan Senate bill that Trump spurned months ago, and enough for building just 55 miles of barricades, not the 200-plus miles he'd sought.

When asked Wednesday if they had an agreement that Trump would approve, Senate Appropriations Committee Chairman Richard Shelby, R-Ala., told reporters: "We think so. We hope so."

The president, though, had been noncommittal about signing.

“Well, we haven’t gotten it yet,” Trump told reporters at the White House on Wednesday. “We’ll be getting it and we’ll be looking for land mines — because you could have that.”

Trump's assent would end a raucous legislative saga that commenced before Christmas and appeared to approach its ending, almost fittingly, on Valentine's Day. The low point was the historically long 35-day partial federal shutdown, which Trump sparked and was in full force when Democrats took control of the House, compelling him to share power for the first time.

Trump yielded on the shutdown Jan. 25 after public opinion turned against him and congressional Republicans. He'd won not a nickel of the $5.7 billion he'd demanded for the wall but had caused missed paychecks for legions of federal workers and contractors and lost government services for countless others. It was seen as a political fiasco for Trump and an early triumph for House Speaker Nancy Pelosi, D-Calif.

The fight left both parties dead set against another shutdown. That sentiment weakened Trump's hand and fueled the bipartisan deal, a pact that has contrasted with the parties' still-raging differences over health care, taxes and investigations of the president.

Notably, the word "wall" — which fueled many a chant at Trump campaign events and then his rallies as president — does not appear once in the 1,768 pages of legislation and explanatory materials. "Barriers" and "fencing" are the nouns of choice.

The compromise also would squeeze funding for Immigration and Customs Enforcement, or ICE, in an attempt to pressure the agency to detain fewer immigrants gradually. To the dismay of Democrats, it would still leave an agency many of them consider abusive holding thousands more immigrants than it did last year.

The measure contains money for improved surveillance equipment, more customs agents and humanitarian aid for detained immigrants. The overall bill also provides $330 billion to finance dozens of federal programs for the rest of the year, one-fourth of federal agency budgets.

Trump has talked for weeks about augmenting the agreement by taking executive action to divert money from other programs for wall construction, without congressional sign-off.

Those moves could prompt congressional resistance or lawsuits, but would help assuage supporters dismayed that the president may be yielding.

Fox News’ Chad Pergram, David Spunt, Jennifer Bowman and The Associated Press contributed to this report.