FILE - This Oct. 26, 2017 file photo shows prototypes of border walls in San Diego. A federal judge in San Diego who was taunted by Donald Trump during the presidential campaign has sided with the president on a challenge to building a border wall with Mexico. U.S. District Judge Gonzalo Curiel on Tuesday, Feb. 27, 2018 rejected arguments by the state of California and advocacy groups that the administration overreached by waiving laws requiring environmental and other reviews before construction could begin. (AP Photo/Elliott Spagat, File)

FILE - This Oct. 26, 2017 file photo shows prototypes of border walls in San Diego. A federal judge in San Diego who was taunted by Donald Trump during the presidential campaign has sided with the president on a challenge to building a border wall with Mexico. U.S. District Judge Gonzalo Curiel on Tuesday, Feb. 27, 2018 rejected arguments by the state of California and advocacy groups that the administration overreached by waiving laws requiring environmental and other reviews before construction could begin. (AP Photo/Elliott Spagat, File)

SAN DIEGO (AP) — A judge who was taunted by Donald Trump during the presidential campaign sided with the president Tuesday on a challenge to building a border wall with Mexico, removing what could have been a major obstacle to the signature campaign pledge.

U.S. District Judge Gonzalo Curiel rejected arguments by the state of California and advocacy groups that the administration overreached by waiving laws requiring environmental and other reviews before construction can begin. Plaintiffs in the lawsuit said a 2005 a law that gave the Homeland Security secretary broad authority to waive the reviews had expired.

ADVERTISEMENT

“Big legal win today,” Trump tweeted in response to the ruling. He didn’t mention his prior remarks about the judge.

Trump berated Curiel during the campaign for his handling of fraud allegations against now-defunct Trump University, suggesting the Indiana-born judge’s Mexican heritage reflected a bias.

Curiel mentioned his roots in his 101-page ruling Tuesday when he cited another native of the state, U.S. Supreme Court Chief Justice John Roberts, who wrote in another case that courts should not make policy judgments.

“The court cannot and does not consider whether the underlying decisions to construct border barriers are politically wise or prudent,” Curiel wrote.

The lawsuit was the first major legal challenge to the wall under Trump and the latest legal challenge to fail over the years.

The Center for Biological Diversity, which sued along with the state of California and three advocacy groups, said it would appeal.

“They’re giving unprecedented, sweeping power to an unelected agency chief to ignore dozens of laws and crash through hundreds of miles of spectacular borderlands,” attorney Brian Segee said, referring to the head of Homeland Security. “This is unconstitutional and shouldn’t be allowed to stand.”

California Attorney General Xavier Becerra said, “We will evaluate all of our options and are prepared to do what is necessary to protect our people, our values, and our economy from federal overreach.”

The Animal Legal Defense Fund said it may ask the U.S. Supreme Court to intervene. The Sierra Club said the environmental and other reviews are critical to protecting border communities, but the group didn’t discuss its next step.

U.S. Justice Department spokesman Devin O’Malley welcomed the decision, saying Congress granted authority to build a wall without delay and that the administration is pleased it can continue “this important work vital to our nation’s interests.”

ADVERTISEMENT

Homeland Security spokesman Tyler Houlton added, “Simply put, walls work.”

The decision came days after construction began on a 30-foot (9.1-meter) high barrier in Calexico, California, the administration’s first wall project outside of eight prototypes in San Diego that were completed in October.

The administration has issued three waivers since August, two to build in parts of California and one in part of New Mexico. President George W. Bush’s administration issued the previous five waivers, allowing the government to quickly extend barriers to about one-third of the border.

The Center for Biological Diversity said in its lawsuit that the waiver authority cannot be interpreted to last forever. California argued that it expired in 2008, when Homeland Security satisfied congressional requirements at the time on how much wall to build.

Curiel wrote that the law certainly “is not a model of legislative precision” and that both sides made plausible arguments.

The judge declined to second-guess the administration’s findings that waivers were issued in areas of “high illegal entry,” a requirement set by Congress. The advocates argued that dramatic declines in border arrests undermined those findings.

During 2½ hours of arguments this month, the judge peppered both sides with questions about the law’s meaning. He showed strong interest in a requirement tacked on in late 2007 for Homeland Security to consult other federal agencies, state and local governments, Indian tribes and property owners to minimize the impact of construction, which challengers said the administration failed to do.

Curiel said in his ruling that the law’s lack of specifics prevented him for concluding that the administration failed to properly consult others.

Trump is seeking $18 billion to extend the wall as the White House and Congress are at an impasse. Earlier this month, the Senate rejected an administration-backed plan to link funding and sharp cuts to legal immigration to allowing young immigrants to stay in the country after they were temporarily shielded from deportation under an Obama-era program, Deferred Action for Childhood Arrivals.

The wall prototypes in San Diego that were built to guide future designs and the wall replacement in Calexico were previously funded.

Curiel was pilloried by Trump over the Trump University lawsuits. The then-presumptive Republican presidential nominee called him a “hater” of Trump who should be ashamed, calling attention to the judge’s Mexican ancestry and Trump’s support for a border wall.

Trump settled the lawsuits for $25 million after winning the election, without admitting wrongdoing.