A Southern California judge, once disparaged by President Donald Trump, ruled in his favor Tuesday in a lawsuit challenging Department of Homeland Security decisions related to Trump's plans for a wall along the southern border.

The state of California and several environmental advocacy groups brought three lawsuits last year against DHS, which were consolidated into one before U.S. District Judge Gonzalo Curiel of the Southern District of California. The lawsuits challenged waivers signed by former DHS Secretaries John Kelly and Elaine Duke, pursuant to the 1996 Illegal Immigration Reform and Immigrant Responsibility Act, to allow construction of the wall.

The plaintiffs alleged DHS exceeded its authority in issuing the waivers, as well as various constitutional violations.

In a 101-page opinion, Curiel wrote that he “does not have serious constitutional doubts” about the immigration law allowing for such waivers, and that the DHS secretaries did not act “in excess of their delegated powers” in issuing them.

During the 2016 presidential election, Trump alleged that Curiel, who oversaw a case against Trump University, was biased against the then-candidate because the judge is Hispanic.

The judge noted in his Tuesday opinion that the border wall is the “subject of heated political debate,” but said the court “cannot and does not consider whether underlying decisions to construct the border barriers are politically wise or prudent.”

Curiel also quoted his “fellow Indiana native,” U.S. Supreme Court Chief Justice John Roberts, on handling cases “surrounded by political disagreement.”

“Court[s] are vested with the authority to interpret the law; we possess neither the expertise nor the prerogative to make policy judgments,” Curiel wrote, quoting Roberts' 2012 U.S. Supreme Court opinion upholding the Affordable Care Act. “Those decisions are entrusted to our nation's elected leaders, who can be thrown out of office if the people disagree with them. It is not our job to protect the people from the consequences of their political choices.”

In a statement, U.S. Department of Justice spokesman Devin O'Malley said border security is “paramount” to stifling illegal immigration.

“Congress gave authority to the Department of Homeland Security to construct a border wall without delay to prevent illegal entry into the United States, and we are pleased DHS can continue this important work vital to our nation's interests,” O'Malley said.

California Attorney General Xavier Becerra, who has filed more than two dozen lawsuits against the Trump administration, said in a statement that Trump's wall is “medieval” and “does not belong in the 21st century.” The AG did not say yet if the state will appeal.

“We remain unwavering in our belief that the Trump administration is ignoring laws it doesn't like in order to resuscitate a campaign talking point of building a wall on our southern border,” 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.”