Donald Trump is signing a federal funding bill to avoid another government shutdown and announcing a series of executive actions along the US-Mexico border, including the declaration of a national emergency – setting the stage for a major legal showdown.

The border security compromise was approved by congress on Thursday afternoon as the president threatened to declare a national emergency if the billions of dollars he requested to go towards building a wall was not included in the bill.

The measure reportedly includes just $1.4bn (£1bn) for “border barriers,” much less than what the president had previously demanded, and less than previous bipartisan measures had approved for barrier funding.

“It’s a great thing to do because we have an invasion of drugs, an invasion of gangs, an invasion of people, and it’s unacceptable,” Mr Trump said while announcing the national emergency he declared along the US-Mexico border on Friday.

The president’s border wall executive actions are expected to circumvent money from funds targeted for military construction and counterdrug efforts.

“The order is signed,” the president declared. “We will have a national emergency and we will then be sued, and they will sue us in the 9th Circuit, even though it shouldn't be there, and we will possibly get a bad ruling and then we'll get another bad ruling and then we'll end up in the Supreme Court,” he continued, adding the nation’s highest court will “hopefully” provide a "fair shake".

Trump shuts down US government over Mexico border wall – in pictures Show all 15 1 /15 Trump shuts down US government over Mexico border wall – in pictures Trump shuts down US government over Mexico border wall – in pictures Federal workers and contractors rally against the partial federal government shutdown Getty Images Trump shuts down US government over Mexico border wall – in pictures The US Capitol on the first morning of a partial government shutdown in Washington EPA Trump shuts down US government over Mexico border wall – in pictures Federal workers and contractors rally against the partial federal government shutdown Getty Trump shuts down US government over Mexico border wall – in pictures President Trump speaks with children who called the North American Aerospace Defense Command Santa tracker in the State Dining Room of the White House. He earlier in the day, tweeted that he was 'all alone in the White House' waiting for Democrats to make a deal on border security EPA Trump shuts down US government over Mexico border wall – in pictures Furloughed federal workers pick up free food at a pop-up store of Kraft Heinz Getty Images Trump shuts down US government over Mexico border wall – in pictures Hundreds of federal workers and contractors rally against the partial federal government shutdown Getty Trump shuts down US government over Mexico border wall – in pictures A pedestrian walk past the U.S. Capitol ahead of a possible partial government shut down in Washington, U.S., December 20, 2018. REUTERS/Joshua Roberts JOSHUA ROBERTS Reuters Trump shuts down US government over Mexico border wall – in pictures From left, House Majority Leader Steny Hoyer, Senate Minority Leader Chuck Schumer, Sen. Dick Durbin and Speaker of the House Nancy Pelosi walk to speak to reporters after meeting with President Donald Trump about border security in the Situation Room of the White House. Trump declared he could keep parts of the government shut down for "months or even years" as he and Democratic leaders failed in a second closed-door meeting to resolve his demand for billions of dollars for a border wall with Mexico Evan Vucci AP Trump shuts down US government over Mexico border wall – in pictures Federal workers and contractors rally against the partial federal government shutdown Getty Images Trump shuts down US government over Mexico border wall – in pictures A sign alerts visitors to the closure of the National Archives on the fifth day of a partial government shutdown EPA Trump shuts down US government over Mexico border wall – in pictures Hundreds of federal workers and contractors rally against the partial federal government shutdown Getty Images Trump shuts down US government over Mexico border wall – in pictures Visitors read signs announcing the closure of the White House Visitor Center EPA Trump shuts down US government over Mexico border wall – in pictures President Donald Trump speaks during a round-table discussion on border security and safe communities with State, local, and community leaders in the Cabinet Room of the White House Getty Images Trump shuts down US government over Mexico border wall – in pictures A sign alerts visitors to the closure of the White House Visitor Center on the first day of a partial government shutdown EPA Trump shuts down US government over Mexico border wall – in pictures Furloughed federal workers show their IDs for entering a pop-up store of Kraft Heinz Getty Images

The uproar over Trump’s latest move casts a shadow over what had been a rare display of bipartisanship to address the grinding battle between the White House and lawmakers over border security.

The Senate passed the legislation 83-16, with both parties solidly aboard. The House followed with a 300-128 tally.

Despite widespread opposition in congress to proclaiming an emergency, including by some Republicans, Mr Trump was responding to pressure to act unilaterally to soothe his conservative base and avoid appearing like he’s lost his wall battle.

Word that the president would declare the emergency prompted condemnations from Democrats and threats of lawsuits from states and others who might lose federal money or said he was abusing his authority.

In an unusual joint statement, House speaker Nancy Pelosi and Senate minority leader Chuck Schumer said such the declaration would be “a lawless act, a gross abuse of the power of the presidency and a desperate attempt to distract” from Mr Trump’s failure to force Mexico to pay for the wall, as he’s promised for years.

Support free-thinking journalism and attend Independent events

“Congress will defend our constitutional authorities,” they said. They declined to say whether that meant lawsuits or votes on resolutions to prevent Trump from unilaterally shifting money to wall-building, with aides saying they’d "wait to see what he does".