Updated at 12:30 p.m. Friday: Revised to reflect Trump announcement.

WASHINGTON — Hours after threatening to veto a massive spending bill that provided little funding for his long-promised border wall, President Donald Trump backed down and signed the deal Friday — averting a government shutdown that would have begun at midnight. "Not happy with $1.6 billion, but it does start the wall," Trump said.

His budget director announced flatly on Thursday that the president would sign the $1.3 trillion deal despite disappointment that Congress rejected a $25 billion demand for the wall. The deal includes just $1.6 billion for the project, and only 33 miles for barriers in areas that aren't already fenced — a fraction of Trump's goal.

"There are a lot of things that I'm unhappy about in this bill," he said in a nationally televised announcement, asserting that he had no choice but to sign the bill because it boosts military spending. "I'm never going to sign another bill like this again. ... Nobody read it. It's only hours old."

On Friday morning, Trump apparently had second thoughts. Venting his ire via Twitter, he threatened a veto, which raised the specter of a prolonged federal shutdown because lawmakers had already scattered to their home states for a two-week recess.

"I looked very seriously at the veto. I was thinking about doing the veto," but the military funding was paramount, he said.

Reneging on the deal would have been extraordinary -- as was the shutdown threat.

"The border, we've worked very hard on. ... We have a lot of money coming to the border," Trump said. "We're going to be starting work literally on Monday on some new wall — not enough — but also on fixing existing walls and existing fences," Trump said. "This is a short term funding but ... it starts immediately."

The House passed the plan Thursday afternoon and the Senate followed after midnight, with little time to spare before a shutdown deadline at midnight Friday.

"I am considering a VETO of the Omnibus Spending Bill based on the fact that the 800,000 plus DACA recipients have been totally abandoned by the Democrats (not even mentioned in Bill) and the BORDER WALL, which is desperately needed for our National Defense, is not fully funded," Trump tweeted Friday morning.

The 16-day shutdown in fall 2013 cost the national economy more than $1 billion a day. The stock market is already reeling from a looming trade war with China announced Thursday.

There is no indication that Trump used the spending deal to push for a resolution of the dispute over the Deferred Action for Childhood Arrivals program, despite the 11th hour injection of that issue.

In recent months, Trump demanded $25 billion in wall funding in exchange for a sweeping overhaul of immigration policy and protection for young immigrants facing potential deportation, but the proposal gained little traction in Congress, in either party.

Homeland Security Secretary Kirstjen Nielsen, appearing with the president Friday in the Diplomatic Reception Room of the White House, called the wall funding a "down payment" on a wall system.

Critics of Trump's wall proposal complain that he is overly focused on a physical barrier. A "system," by contrast, includes a combination of barriers, surveillance technology and personnel.

Top aides insisted on Thursday that Trump was satisfied with the wall funding in the budget deal and had not abandoned his vision of a "big beautiful wall," even if the political climate in Washington doesn't allow him to secure it quite yet.

"We got 110 miles. We need 10 times that," said White House budget director Mick Mulvaney. "The bottom line is, if Congress will appropriate the money, we will build the wall today."

I am considering a VETO of the Omnibus Spending Bill based on the fact that the 800,000 plus DACA recipients have been totally abandoned by the Democrats (not even mentioned in Bill) and the BORDER WALL, which is desperately needed for our National Defense, is not fully funded. — Donald J. Trump (@realDonaldTrump) March 23, 2018

DACA was abandoned by the Democrats. Very unfair to them! Would have been tied to desperately needed Wall. — Donald J. Trump (@realDonaldTrump) March 23, 2018

Of the 110 miles of barrier authorized, only about 33 miles would go in areas that don't already have some sort of fence.

Trump's second thoughts about the deal came after a news cycle filled with commentary about a major setback on a signature campaign promise, with the most caustic comments that he was outright rolled by Democrats.

The 2,232-page bill includes language that explicitly limits wall construction to

"operationally effective designs" deployed by March 2017.

That would rule out the prototypes Trump inspected in San Diego last week, though Mulvaney insisted otherwise.

He offered no explanation for the discrepancy and on Friday, his aides ignored requests to explain the discrepancy between his assurance Thursday that Trump would sign the bill and the president's last-minute veto threat.

Trump vowed throughout his campaign to build a wall and to make Mexico pay for it. He has yet to propose any mechanism by which to wrest the payment from Mexico's government or its citizens, and the funding in the latest spending plan would come from ordinary federal revenue -- in other words, U.S. taxpayers.

Got $1.6 Billion to start Wall on Southern Border, rest will be forthcoming. Most importantly, got $700 Billion to rebuild our Military, $716 Billion next year...most ever. Had to waste money on Dem giveaways in order to take care of military pay increase and new equipment. — Donald J. Trump (@realDonaldTrump) March 22, 2018

Thursday night, Sen. Ted Cruz cited a lack of wall funding as one reason he'll vote against the $1.3 billion omnibus spending deal. "It fails to provide sufficient funds to properly secure our border, let alone build the wall that is necessary," he said in a statement.

Tied to DACA

In late January, Trump dangled protection for 1.8 million young immigrants in exchange for $25 billion for border wall construction. That plan also would have included major curbs on legal immigration, and a shift from family-based visas and a lottery system to one that favors highly skilled immigrants.

The young immigrants face deportation because last fall, Trump scrapped the Obama-era DACA program, which shielded foreign-born U.S. residents who'd been brought into the country illegally as children.

Democrats rejected the proposal, which they viewed as draconian. They also rejected a fallback offer in the past week tying three years of DACA protection to $25 billion for the wall.

Mulvaney insisted that Democrats view DACA "as a political weapon. ... They want to use the permit holders as political pawns in their game." Democrats accuse Trump of manufacturing the crisis by scrapping DACA, then demanding concessions in exchange for protecting victims of his own actions.

Despite the setback on the president's signature campaign promise, aides took heart in the fact that wall foes were unhappy the spending plan included funds for the project.

The Congressional Hispanic Caucus opposes the deal on grounds that "it would fund Trump's border wall and mass deportation force" without protecting DACA recipients, often called "Dreamers."

Their plight remains uncertain. Federal courts have temporarily kept protections in place since the March 5 deadline set by Trump passed.

Sen. John Cornyn of Texas, the deputy Senate majority leader and one of many Republicans openly skeptical of Trump's expansive border wall vision, said funding for surveillance technology and personnel "is money well spent."

The spending deal includes a ban on construction in the Santa Ana National Wildlife Refuge in Hidalgo County - a win for environmentalists who have warned that roads and fences would destroy an important ecosystem.

"It is a vulnerability," Cornyn said, adding that he has conferred with Border Patrol and U.S. Fish and Wildlife Service officials as they seek ways to beef up security while protecting the refuge. "My hope is that it would be more technology driven and less physical infrastructure, because I hate to see us unnecessarily damage such a magnet for tourism and economic activity there along the border."

The $1.571 billion for barriers along the Southwest border includes:

-- $251 million for 14 miles of secondary fence in San Diego, where primary fencing already exists

-- $445 million for 25 miles of levee fence in the Rio Grande Valley

-- $196 million for 8 miles of pedestrian fence in the Rio Grande Valley

-- $445 million for 63 miles of replacement fence

-- $196 million for border technology

-- $38 million for wall planning and design

Not disappointed

Marc Short, the White House liaison to Congress, said Thursday the government wouldn't have been able to spend any more than that in the next six months anyway, echoing Mulvaney's remarks that the deal is not a disappointment.

"We asked for 28 miles of levee wall in the Rio Grande Valley. We got 25," Mulvaney said. "We asked for 32 miles of pedestrian wall in the Rio Grande Valley. We only got 8 there. We asked for 14 miles in San Diego, OK? And we got all 14 miles. That includes building the new type of wall that the president actually visited last year."

He apparently was referring to Trump's trip to San Diego on March 13 to inspect prototypes, including a steel bollard fence with a rounded concrete top designed to deter grappling hooks.

Mulvaney touted the fact that the bill provides more than the White House had sought for technology, roads, air and marine assets, vehicles, weapons, and for hiring and retaining Border Patrol and immigration and customs officers.

That reflects a consensus in Congress that technology and personnel are a better investment for beefing up border security than a massive barrier.

"We ended up asking for 74 miles worth of wall, we get 110. Not exactly what we wanted, where we want it. Congress chose to ignore some of the suggestions that CBP [Customs and Border Protection] made on where the best kind of wall should go," Mulvaney said.

Washington correspondent Tom Benning contributed to this report.