The federal judge once slammed by President Donald Trump as being a “Mexican” who was incapable of being impartial has sided with Trump in his bid to move ahead with construction of a wall on the U.S.-Mexico border.

Judge Gonzalo P. Curiel on Tuesday rejected arguments by the state of California and a coalition of environmental groups, who said the Trump administration had improperly ignored environmental laws in its push to build the wall.

Judge Gonzalo Curiel San Diego Superior Court

Curiel said in his 101-page ruling that such decisions should be left to other branches of government, not the judiciary. He quoted U.S. Supreme Court Chief Justice John Roberts in saying political matters "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.”

Related: Who is Federal Judge Gonzalo Curiel?

Curiel, who was nominated to the federal bench by President Barack Obama, made it clear his ruling centered on whether the administration had the authority to build a border wall, not on the wisdom of that decision. He described the "heated political debate" surrounding the project and added: "In its review of this case the Court cannot and does not consider whether underlying decisions to construct the border barriers are politically wise or prudent."

The case grew out of a 1996 law, and its amendments, that gave the executive branch power to construct a wall in and near San Diego and to waive environmental review when "necessary to ensure expeditious construction."

The law also limited any federal court reviewing challenges to the construction to only consider Constitutional violations, not challenges based on the environmental laws.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Homeland Security Secretary John Kelly called for a waiver of the environmental reviews last August and the plaintiffs--California, the Center for Biological Diversity, the Sierra Club and the Animal Legal Defense Fund all sued, saying the Kelly had overstepped his authority.

Experts provided declarations for California and the environmental groups, suggesting that the construction — on 15 miles of border in San Diego and another three miles near El Centro — could harm the Tijuana Estuary, along with rare, threatened and endangered species.

Border Patrol agents patrol the US-Mexico border prior to an Easter mass at the fence separating the two countries at Friendship Park on April 16, 2017 in San Ysidro, California. Sandy Huffaker / AFP - Getty Images file

Curiel said the state and environmentalists did not meet the high threshold for holding up the construction: showing that Kelly had acted in excess of his powers.

The plaintiffs had argued that Trump’s Department of Homeland Security had violated the National Environmental Policy Act, the Endangered Species Act and the Coastal Zone Management Act, by not properly consulting with California and other stakeholders on the environmental consequences of the construction in the Golden State.

Curiel agreed that the "belated contact with stakeholders reduces the practical benefit of the consultation process." But he said that the failures were not enough to show that Kelly and an interim director of Homeland Security had overstepped their authority.

“While unlimited judicial review would assure compliance with all legal requirements,” wrote Curiel, who sits on the U.S. District Court in San Diego, “it would defeat the purpose of the law to expedite the construction of border barriers and roads in areas where they are needed.

California Attorney General Xavier Becerra renewed his complaint that the Trump White House was “ignoring laws it doesn’t like in order to resuscitate a campaign talking point of building a wall on our southern border."

Related: Environmentalists sue to block Trump border wall

"A medieval wall along the U.S.-Mexico border simply does not belong in the 21st century.” Becerra said in his statement, noting that California officials were reviewing their options.

Another plaintiff in the case, the Center for Biological Diversity, announced that it would appeal. “The Trump administration has completely overreached its authority in its rush to build this destructive, senseless wall,” said Brian Segee, a senior attorney with the group. "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. This is unconstitutional and shouldn’t be allowed to stand.”

Related: Taco trucks to bad hombres: 7 times Latinos figured in Trump's campaign

Trump had said in June 2016, during the presidential campaign, that Curiel could not fairly judge a pair of class-action lawsuits brought against the real estate magnate for the operation of his for-profit Trump University. The candidate said Curiel would be biased, because he was a Mexican and would be upset by Trump's positions on immigration.

Trump also branded him a "hater" and "very hostile."

Curiel was born in Indiana to parents who were immigrants from Mexico. Trump's remarks prompted outrage from critics, who said he was refusing to acknowledge the judge was an American and capable of impartiality, merely because of his ethnic roots.