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, possibly removing 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 could begin.

"Big legal win today. U.S. judge sided with the Trump Administration and rejected the attempt to stop the government from building a great Border Wall on the Southern Border. Now this important project can go forward!"

Big legal win today. U.S. judge sided with the Trump Administration and rejected the attempt to stop the government from building a great Border Wall on the Southern Border. Now this important project can go forward!

The challengers said a 2005 a law that gave the Homeland Security secretary authority to waive the reviews had expired. The law exempted Homeland Security from dozens of laws if it deemed a wall to be in national security interests.

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 Tuesday's ruling when he quoted 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 chief justice wrote, "It is not our job to protect people from the consequences of their political choices."

"In its review of this case, the court cannot and does not consider whether the underlying decisions to construct border barriers are politically wise or prudent," Curiel wrote in his 101-page ruling.

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 was first to sue the Trump administration, with three other groups — the Sierra Club, Defenders of Wildlife and Animal Legal Defense Fund — later filing a lawsuit. California Attorney General Xavier Becerra, a Democrat, was close behind, and Curiel consolidated all three cases.

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.

During 2½ hours of arguments this month, Curiel peppered both sides with questions about the law's meaning, saying at one point that it "isn't a model of clarity."

Trump is seeking $18 billion to extend the wall as the White House and Congress negotiate an immigration package that would include new spending on border security and grant legal status to young immigrants who were temporarily shielded from deportation under an Obama-era program, Deferred Action for Childhood Arrivals.

The 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 shortly after winning the election, without admitting wrongdoing.