Though Trump climbed down in agreeing to reopen government, he still threatened to renew hostilities.

President Donald Trump on Friday brought a temporary end to the longest government shutdown in US history, while dropping his previous insistence on immediate funding for wall construction along the Mexican border.

The announcement in the White House Rose Garden on the bipartisan deal marked a retreat by Trump, suspending a political row that has paralyzed Washington, disrupted air travel and left more than 800,000 federal employees without pay for five weeks.

The top Democratic senator, Chuck Schumer, said he hoped Trump had "learned his lesson."

The Senate and House of Representatives both passed the deal by unanimous consent Friday. The White House later confirmed Trump had signed it into law.

Trump's reversal came as the full weight of the shutdown, including the financial cost on struggling employees and the national economy, became ever more apparent to the administration and power brokers in Washington, and as the president appeared outfoxed by his political nemesis Nancy Pelosi, the Democratic speaker of the House.

But while the president climbed down in agreeing to reopen government without first getting $5.7 billion in border wall funds, he still threatened to renew hostilities with a new shutdown, or a state of emergency, if there is no breakthrough on his pet project in the next three weeks.

"In a short while, I will sign a bill to open our government," he said. "Over the next 21 days, I expect that both Democrats and Republicans will operate in good faith."

"If we don't get a fair deal from Congress, the government either shuts down on February 15th again, or I will use the powers afforded to me under the laws and Constitution of the United States to address this emergency," he warned.

"We really have no choice but to build a powerful wall or steel barrier."

Shutdown pain

Trump triggered the shutdown in December as a way of putting pressure on congressional Democrats after they refused his wall funding demand.

But Democrats, led by House Speaker Nancy Pelosi, didn't blink, calculating that Trump would be blamed by voters for the ensuing chaos -- and polls showed that they were correct.

Federal workers as varied as museum attendants and US Coast Guard sailors were left without salaries. Even Secret Service agents guarding the White House have been working without pay.

By Friday the impact of the shutdown was focused on airports, where enough federally employed security staff have called in sick to slow down overall operations.

Air traffic controllers were working without pay and in New Jersey's busy Newark Liberty International Airport staffing issues led to delays, raising the specter of a wider degradation of US air travel.

This raised pressure on Trump and his congressional opponents to reach a deal. However, in the end Trump appears to have made the only compromise, even at the risk of angering his right-wing voter base.

Conservative commentator Ann Coulter wasted no time in lashing out at Trump's retreat.

"Good news for George Herbert Walker Bush: As of today, he is no longer the biggest wimp ever to serve as President of the United States," she tweeted, referring to the late president, a Republican moderate.

No way out

Trump says more border walls are needed to stop what he says are crisis levels of criminals and illegal immigration. Democrats say his focus on the wall distracts from more complex immigration problems and is used to whip up his base for political gain.

On Thursday, two competing bills to end the partial shutdown failed in the Senate, underscoring the inability of Democrats and Trump's Republicans to agree on a compromise that would reopen government while committing to wall construction.

Trump has spoken for weeks about using his presidential authority to declare a border emergency and bypass Congress, allowing himself to take funds from other sources for the wall.

However, this would almost certainly be blocked in court challenges.

So while Trump had previously stated he would not "cave" in the standoff, he was left with little alternative.

At his White House announcement, Trump sought to thank the many federal workers who suffered as collateral damage in the political battle, saying they showed "extraordinary devotion in the face of this recent hardship."

But Tiffany Cruz, who works at LaGuardia Airport in New York, which was also badly hit by delays, said she had little faith in Trump.

"He's just reopening (government) at his convenience," she said. "I don't believe he cares about anything but himself."

With the shutdown ending, the question arises whether Trump will be re-invited to deliver his State of the Union address in Congress next Tuesday.

Pelosi, who outfoxed him in the five-week showdown, had insisted he not deliver his speech until government reopened. On Friday she said the schedule remained undecided.