Donald Trump was handed a major victory on his signature issue — building a wall on the US-Mexico border — on Friday, as the US Supreme Court approved the use of $2.5 billion in military funding for the purposes of wall construction.

In a 5-4 decision on Friday, the Supreme Court overturned two decisions by a federal judge that had barred the Trump administration from using military money for the wall. The federal judge had ruled the executive branch could not appropriate money for a purpose not specifically authorized by Congress.

“Wow! Big VICTORY on the Wall,” Trump tweeted in response to the Supreme Court’s decision.

The money in question comes from the Pentagon’s budget; it had been initially approved for military personnel and training purposes. In two separate cases earlier this year, US District Court Judge Haywood S. Gilliam Jr. of Oakland blocked these funds from being reappropriated and put toward building a border wall. The administration argued that such redistribution of government funds was allowable given the president had declared a national emergency at the border in February.

The cases heard by Gilliam were lawsuits brought by the ACLU on behalf of the Sierra Club and Southern Border Communities Coalition, something that became key to the Supreme Court’s decision. In its ruling, the Supreme Court found that private groups are not appropriate parties to challenge the allocation of federal dollars.

Chief Justice John Roberts and Justices Samuel Alito, Neil Gorsuch, Brett Kavanaugh, and Clarence Thomas ruled in favor of lifting Gilliam’s injunction. Justices Ruth Bader Ginsburg, Elena Kagan, and Sonia Sotomayor supported the lower court’s decision.

Justice Stephen Breyer supported neither side and proposed a compromise instead, suggesting the court clear the administration’s path in setting up contracts for construction without allowing it to start building anything.

Litigation over the funding will continue; the case will return to an appeals court. In the meantime, the Trump administration will be able to tap into these funds and begin construction on the wall, reports the New York Times.

The ruling followed an emergency filing from the administration at a time when the Supreme Court is typically on summer recess. The filing stated that a decision needed to be reached so that the Trump administration could spend the money it wanted to appropriate before the federal government’s fiscal year ends in September.

All told, the government plans to divert $6.7 billion from federal agencies, including the US Treasury and the Department of Defense, to construct the wall.

In a statement on Friday night, House speaker Nancy Pelosi criticized the decision.

“The Supreme Court’s decision tonight to allow President Trump to defy the bipartisan will of the Congress and proceed with contracts to spend billions of dollars on his wall undermines the Constitution and the law,” she said.

The court cases were about immigration, the environment, and the Constitution

The construction of a wall along the US-Mexican border has been a signature policy since the earliest days of Donald Trump’s presidential campaign, and challenges to the wall’s construction have been making their way through various US courts for years.

Recent lawsuits argued by the ACLU on behalf of the Sierra Club and Southern Border Communities Coalition have asserted that the wall would “irreparably” harm the environment, and have made the case that executive branch appropriations for the wall represent a misuse of military funding.

The second argument moved the wall debate beyond immigration and environmental policy and into the realm of how separation of powers is outlined in the Constitution. Judges were asked to consider whether the executive branch, overseen by the president, can bypass funding decisions made by Congress. Traditionally, Congress has had to approve the appropriation of funds; this role was outlined in Article I, Section 9, Clause 7 of the Constitution, which states: “No Money shall be drawn from the Treasury, but in Consequence of Appropriations made by Law; and a regular Statement and Account of the Receipts and Expenditures of all public Money shall be published from time to time.”

Congress had previously allocated about $1.4 billion in border funding; the administration requested $6.7 billion. To get around this difference, the Trump administration announced plans to use other federal funds for the wall, arguing that the fact the president had declared a national emergency allowed for the appropriation of funds.

The money at the heart of Friday’s Supreme Court decision — which stemmed from the lawsuits brought by the ACLU and Sierra Club — came from the executive branch’s “reprogramming” of funds earmarked for the military.

In the lower court, federal judge Gilliam twice found that the Trump administration had illegally planned to use misappropriated Congressional funds for the purpose of building the wall.

In June, Gilliam ordered that work be stopped on a stretch of the wall between California and Arizona. Vox’s Gabriela Resto-Montero reported that the $1.5 billion in financing for that 79-mile portion would have come from “military pay and training accounts through a Department of Defense counterdrug program.” In May, Judge Gilliam ruled that a stretch of wall being built between Arizona and Texas likewise could not draw upon reprogrammed $1 billion in Army personnel funds.

Taken together, these two cases blocked access to $2.5 billion of the $6.7 billion that the Trump administration hoped to appropriate for its border wall. Gilliam rejected the argument that the national emergency allowed for the appropriations and ruled that Congress still had to approve the redirection of funding.

At the time, he wrote that the public interest would be “best served by respecting the Constitution’s assignment of the power of the purse to Congress, and by deferring to Congress’s understanding of the public interest as reflected in its repeated denial of more funding for border barrier construction.”

Friday’s decision reverses that decision, effectively freeing up a third of Trump’s requested border wall funding. The environmental groups that brought those challenges were deemed inappropriate parties to bring a lawsuit about transferring federal funds, an argument put forth by US Solicitor General Noel Francisco.

“Interests in hiking, birdwatching, and fishing in designated drug-smuggling corridors do not outweigh the harm to the public from halting the government’s efforts to construct barriers to stanch the flow of illegal narcotics across the southern border,” Francisco said.

The Supreme Court apparently agreed.

The decision is the latest in a series of immigration wins for Trump

Trump heralded the decision as a victory on Twitter:

Wow! Big VICTORY on the Wall. The United States Supreme Court overturns lower court injunction, allows Southern Border Wall to proceed. Big WIN for Border Security and the Rule of Law! — Donald J. Trump (@realDonaldTrump) July 26, 2019

It’s one of several recent wins for his administration’s immigration agenda. A deal with Mexico — announced in June but reached in March — has led to an increased presence of Mexican security forces along that country’s border with Guatemala in order to reduce the number of migrants coming north from Central America. That agreement came after Trump threatened to impose steep tariffs on Mexican imports that would have damaged the nation’s economy.

Border crossings also appear to be on the decline, following Mexico’s changes to its immigration enforcement, and arrests at the border dropped by 28 percent in June.

Another win came on the same day as the Supreme Court decision. Earlier on Friday, Trump signed a deal alongside Guatemalan President Jimmy Morales that will direct Central American migrants seeking asylum in the United States to first apply for asylum in Guatemala instead.

The Trump administration has long pursued such a deal with both Guatemala and Mexico; Mexico has made it clear it has no plans to sign such an agreement. Guatemala had refused to sign the deal as well, until relenting under economic pressure Friday.

The Trump administration hopes the agreement will curb asylum applications from Honduras and El Salvador, the Central American countries that neighbor Guatemala and countries from which the bulk of asylum seekers at the US border originate.

As Vox’s Jen Kirby has reported, this policy “would, with few exceptions, make it extraordinarily difficult for anyone not coming from Mexico or on a plane to be eligible for asylum in the US.”

Despite the Supreme Court’s decision, court challenges to the US-Mexico border wall remain

The wall was one of Trump’s signature campaign issues; he has said that it will curb trafficking and illegal immigration at the southern border. Opponents, including Congressional Democrats, say the wall is immoral — and pricey.

Fights over the wall have been ongoing since Trump took office, and Congress has repeatedly declined to provide wall funding. Notably, this resulted in a partial government shutdown that began in December of last year and lasted for 35 days.

In April, House Democrats said they would sue the Trump administration over his use of a national emergency to try and free up funds. They lost that case but have signaled they plan to file an appeal.

And that case isn’t the only one the Trump administration faces. Despite Friday’s Supreme Court decision, opponents to the border wall will continue to challenge its construction in the courts. In fact, the ACLU and Sierra Club cases will continue to be litigated in lower courts.

“We will be asking the federal appeals court to expedite the ongoing appeals proceeding to halt the irreversible and imminent damage from Trump’s border wall,” Dror Ladin, an attorney with the ACLU, said in a statement. “Our Constitution’s separation of powers will be permanently harmed should Trump get away with pillaging military funds for a xenophobic border wall Congress denied.”