President Donald Trump has yielded to political pressure to end the longest US government shutdown in history.
After 35 days, he backed a deal to fund federal agencies for three weeks, but it includes none of the money he has demanded for a US-Mexico border wall.
The Republican president previously vowed to reject any budget unless it included $5.7bn (£4.3bn) to fund his signature campaign pledge.
But Democrats, who control the House of Representatives, flatly refused.
Later on Friday, the Senate and House unanimously passed a bill to temporarily end the shutdown, after which President Trump signed the bill into law.
Following the votes in Congress, Mr Trump tweeted that his decision had been “in no way a concession”, but was “taking care of the millions of people who were getting badly hurt by the shutdown”.
Speaking in the White House Rose Garden, Mr Trump said he was “very proud to announce” the agreement, which will fund the government until 15 February.
He said federal workers affected by the political imbroglio, whom he called “incredible patriots”, would receive full back-pay.
Mr Trump also said he would not yet resort to “a very powerful alternative” – an apparent reference to declaring a national emergency.
This could divert military funding towards building a southern border wall, but such a proclamation would provoke constitutional uproar and legal challenges.
However, the president added: “We really have no choice but to build a powerful wall or steel barrier.
“If we don’t get a fair deal from Congress the government will either shut down on February 15 again, or I will use the powers afforded to me under the laws and the constitution of the United States to address this emergency.”
Mr Trump accepted the deal after hearing of the shutdown’s strain on law enforcement agencies, an administration official told Reuters news agency.
The president is prepared to haggle on the $5.7bn he has been demanding for the border barrier, the same official said.
For more than a month, Donald Trump insisted he would not support reopening the federal government without funding for his border wall.
On Friday, as the fallout from the partial shutdown sent tremors through the US aviation system, the president backed down.
Before all this began, Republican Senate majority leader Mitch McConnell reportedly warned the president that there was no clear way to win a shutdown standoff with Democrats, who – flush off their November election victories – wouldn’t relent.
The wily Kentucky senator, with more than a few legislative victories under his belt, was vindicated.
That must be cold comfort for congressional Republicans, who have watched their party – and the president – take the brunt of the blame for the impasse. And it now sets up a three-week period of frenetic negotiations to reach a border security agreement.
If the federal employees have been drowning because of the shutdown, this temporary funding agreement gives them a chance for a desperate gulp of air.
In three weeks, another shutdown looms, however. Or, the president warned, he could declare a national emergency and take the border battle to the courts.
Either way, the president has retreated – but the fight is far from over.
With opinion polls showing most Americans blamed Mr Trump for the shutdown, he opted for a way out that had been pushed for weeks by the Democratic leader of the House, Speaker Nancy Pelosi.
The outcome was widely seen as a resounding victory for her.
Lawmakers in her party lavished praise on the California congresswoman’s refusal to give ground.
Some conservatives seemed to agree.
“Trump is a broken man. It’s over for him,” tweeted commentator Mike Cernovich, who has a large social media following of the president’s voters.
He said Mr Trump had been outmanoeuvred by the “alpha” House speaker.
Headlines on the conservative Drudge Report and Breitbart News screamed in red letters that there would be no wall funds.
Right-wing commentator Ann Coulter called Mr Trump “the biggest wimp ever to serve as president”.
Some 800,000 civil servants missed another payday on Friday amid the five-week closure of about a quarter of the federal government.
Earlier on Friday, hundreds of flights were grounded or delayed at US airports because of unpaid air traffic controllers calling in sick.
The Federal Aviation Administration (FAA) halted arrivals for about an hour at New York’s LaGuardia Airport.
Flights were also delayed at Newark Liberty International Airport and Philadelphia International Airport because of staff shortages, the FAA said.
Meanwhile, thousands of Internal Revenue Service (IRS) employees failed to show up after they were ordered to return to work unpaid, the Washington Post reported.
The Trump administration recalled 26,000 IRS workers this week to handle the looming tax filing season.
But about 14,000 of them did not come back as of Tuesday, IRS officials told members of Congress.
FBI Director Christopher Wray said in a video message to agents on Friday: “I’m about as angry as I’ve been in a long, long time.”
He said of the shutdown’s effects on his agency: “It’s mind-boggling, it’s short-sighted, and it’s unfair.”
His remarks came after an FBI report this week revealed its resources were at “breaking point”.