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 row that 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 clear, and as the president appeared outfoxed by his political nemesis Nancy Pelosi, the Democratic speaker of the House of Representatives. But while Trump 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. "Over the next 21 days, I expect that both Democrats and Republicans will operate in good faith," he said as he announced he would reopen the government. "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." S&P Global Ratings said late Friday that the shutdown cost "is likely worse than what we had previously expected." Based on their analysis, "the US economy lost at least $6 billion ... larger than the $5.7 billion that the White House requested for the border wall," it said in a statement. - Shutdown pain - Trump triggered the shutdown in December to pressure congressional Democrats to give him funding for the border wall. But the House Democrats calculated that voters would blame Trump for the ensuing chaos -- and polls showed they were correct. Federal workers as varied as museum employees 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 shutdown impact was focused on airports, where enough federally employed security staff had 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 to reach a deal -- and Trump buckled, even at the risk of angering his right-wing voter base. Conservative commentator Ann Coulter wasted no time in lashing out. "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 to reopen government and commit 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 challenged in court. So while Trump had said he would not "cave" in the standoff, the president was left with little alternative. At his White House announcement, Trump sought to thank the 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.