WASHINGTON — President Trump knew that lawmakers were unlikely to ever give him the billions of dollars he wanted to build a wall on the southern border, so in early 2018, he gave aides a directive: Find a way to do it without Congress.
It was hardly an easy assignment. The White House had some flexibility to spend money the way it wanted, but could not move the necessary billions at will. Trump could declare a national emergency, but White House attorneys repeatedly warned him the risk of failure in court was high.
On Friday, Trump did it anyway. Stepping to a microphone in the Rose Garden, the president told reporters he was invoking his powers to declare a national emergency, then acknowledged what his lawyers had been warning him: He will get sued and, at least initially, will probably lose.
The remarkable moment, people familiar with the matter say, marked the culmination of months of heated internal deliberations between the White House Counsel’s Office, the Justice Department, the Office of Management and Budget, lawmakers, and the president over how to fund the wall.
Trump — who had vacillated on whether the dramatic step was the right one — said he was deeply frustrated his wall hadn’t been funded earlier in his administration and was setting that right.
‘‘But we’re stepping up now,’’ Trump said. ‘‘We’re getting it done.’’
The announcement was greeted immediately with promises of legal action from states, lawmakers, and advocacy groups. Inside the Justice Department’s civil division, lawyers braced for what has become a grim reality in the Trump administration: They would be in court again soon, fighting an uphill battle.
White House lawyers, including White House counsel Pat Cipollone, had repeatedly warned Trump of the legal risks of proceeding.
On Friday, some White House lawyers were frustrated, and still skeptical of the commander in chief’s rationale, according to people familiar with the matter who, like others, spoke on the condition of anonymity.
‘‘Look, I expect to be sued,’’ Trump said in the Rose Garden, adding later that ‘‘they will sue us in the Ninth 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, and hopefully we’ll get a fair shake and we’ll win in the Supreme Court.’’
Building a wall on the southern border was a cornerstone of Trump’s presidential campaign, and even before Democrats took control of the House, he had stewed over his inability to make it a reality. The tension came to a head in a March meeting in the White House residence, when Trump learned that his aides had secured only $1.6 billion for border fencing in an omnibus spending bill.
Trump fumed to then-House speaker Paul Ryan that the funding was a fraction of what he would need and threatened not to sign the measure, according to two people with knowledge of the conversation.
‘‘We gave you what you wanted!’’ Ryan shot back, the two said.
Swearing profusely, Trump said that was not true and asked Ryan who had relayed such a message. Ryan said it was Trump’s own aides who negotiated the bill, including Marc Short, then the White House legislative affairs director, the people said.
Around that time, aides put out a statement saying the president would sign the bill. That sent Trump into a rage. At one point, he declared the aides did not represent him and the statement should be rescinded, the people said. He was eventually convinced by his equally angry chief of staff, John Kelly, to sign the measure — although he remained furious with Ryan and his own team.
Soon thereafter, Trump told aides he had to find a way to get his wall without Congress.
While the emergency declaration was controversial internally, it was not without its supporters, people familiar with the matter said. Acting White House chief of staff Mick Mulvaney was a particularly aggressive advocate, having initially formulated the idea in his role as director of the Office of Management and Budget and presented the president with a lengthy memo describing how it would work, the people familiar with the matter said.
As is normal in cases of national emergency, the Justice Department’s Office of Legal Counsel also reviewed the declaration for ‘‘form and legality,’’ and ultimately gave its blessing, people familiar with the matter said.
The legal defense of the declaration, though, is expected to be difficult. White House and Justice Department lawyers are planning to challenge in particular the legal standing of those who plan to sue, and they are contemplating ways to keep the case out of courts that might be unsympathetic to the administration’s position, officials said.
The administration told surrogates on a call Friday morning that they are looking for ways to stop California, in particular, from bringing a lawsuit. Such a suit would likely come in the Court of Appeals for the Ninth Circuit, where the Trump administration has seen a series of legal defeats.
Mulvaney told reporters Friday that the declaration would give Trump access ‘‘to roughly $8 billion worth of money that can be used to secure the southern border,’’ and that the dramatic step was necessary because Congress wouldn’t act.
Trump did sign a spending bill Friday that averted a second government shutdown over the border wall standoff, though the deal included less than a quarter of the money Trump had wanted for the wall. For a time, his signature seemed in doubt.
After a briefing from Homeland Security Secretary Kirstjen Nielsen and others Thursday on details of the final deal, Trump suggested he would not sign - which potentially would have caused another shutdown.
Trump was persuaded to stay on board, but he said he would also declare a national emergency, something Republican leaders had urged him to avoid.
Trump argued in the Rose Garden that declaring an emergency was necessary because narcotics are pouring across the border.