Donald Trump’s highly personal, racially tinged attacks on a federal judge overseeing a pair of lawsuits against him have set off a wave of alarm among legal experts, who worry that the ­Republican presidential candidate’s vendetta signals a remarkable disregard for judicial independence.

That attitude, many argue, could carry constitutional implications if Trump becomes president.

U.S. District Judge Gonzalo Curiel, who is handling two class-action lawsuits against Trump University in San Diego, has emerged as a central target for Trump and his supporters in recent weeks. The enmity only escalated after Curiel ordered the release of embarrassing internal documents detailing predatory marketing practices at the for-profit educational venture; that case is set to go to trial after the November election.

“I have a judge who is a hater of Donald Trump, a hater. He’s a hater,” Trump said at a campaign rally in San Diego, adding that he believed the Indiana-born judge was “Mexican.”

He also suggested taking action against the judge after the election: “They ought to look into Judge Curiel, because what Judge Curiel is doing is a total disgrace. Okay? But we will come back in November. Wouldn’t that be wild if I am president and come back and do a civil case? Where everybody likes it. Okay. This is called life, folks.”

Donald Trump is being sued by former customers of Trump University. Here's everything you need to know about the ill-fated business venture. (Peter Stevenson/The Washington Post)

The courtroom proceedings come with high stakes for Trump, whose likely tough ­general-election fight against Hillary Clinton will leave him open to intense scrutiny of his character, business practices and temperament. Clinton said Wednesday that the Trump University allegations are “just more evidence that Donald Trump himself is a fraud.”

Trump’s strikingly personal attacks on Curiel are highly unusual and have prompted questions about how he would react to adverse judicial decisions should he become president. Trump’s remarks also stand out because he has a personal financial stake in the case.

“Having a presidential candidate embroiled in litigation totally unrelated to the political system . . . that is what is so novel about this. And then you add to this the personal criticism,” said Arthur Hellman, a law professor at the University of Pittsburgh. “It’s personal all the way, and that’s what makes this different.”

Conflicts between the courts and the political branches are common and, to some degree, expected. The Constitution mandates lifetime tenure for federal judges who serve in “good behavior” and protects them against recrimination by forbidding that their salaries be diminished.

Judicial appointments are among a president’s most lasting legacies, and in the current presidential campaign, candidates from both parties have gone beyond the comfort level of many legal experts by issuing litmus tests. On the Democratic side, Clinton and Sen. Bernie Sanders (Vt.) have said overturning the Supreme Court’s controversial Citizens United ruling should be a priority, while Republican candidates went after Chief Justice John G. Roberts Jr. for his votes upholding the Affordable Care Act.

President Obama prompted outrage among conservatives in 2010 when he blasted the Citizens United ruling in his State of the Union address. Republican members of Congress criticized the president for attacking the decision with members of the court seated just feet away from him, while Democrats defended the comments as within the bounds of policy debate.

Trump’s attacks on Curiel stand out for their personal nature, for the racial remarks and for the suggestion by a potential president that someone “ought to look into” the judge.

Charles Gardner Geyh, a professor at Indiana University’s Maurer School of Law, said he has no problem with presidents or presidential candidates criticizing judges or judicial decisions. But, he said, “there’s a line between disagreement and sort of throwing the judiciary under the bus that I think is at issue here.”

One of Trump’s earlier jeremiads came in February, when he told Fox News that Curiel was biased against him because of his controversial immigration comments and proposals, including his promises to build a giant wall on the U.S.-Mexico border and deport 11 million illegal immigrants.

“I think it has to do with perhaps the fact that I’m very, very strong on the border,” Trump said then. “Now, he is Hispanic, I believe. He is a very hostile judge to me.”

Trump returned to ethnicity at last week’s San Diego rally, where he erroneously suggested Curiel was from Mexico: “The judge, who happens to be, we believe, Mexican, which is great. I think that’s fine. You know what? I think the Mexicans are going to end up loving Donald Trump when I give all these jobs, okay?”

Curiel, who through his office declined to comment, was born in East Chicago, Ind., and is a 1979 graduate of the Indiana University law school. He gained acclaim prosecuting drug traffickers along the Tijuana corridor and was reportedly targeted for assassination by the Felix cartel; he joined the federal bench in 2012 after being nominated by Obama.

Katrina Pierson, a spokeswoman for Trump, has expanded on the accusations of bias, wrongly suggesting Curiel is part of a group organizing protests at Trump rallies around California. Curiel is a member of the San Diego La Raza Lawyers Association, a professional group that she appeared to confuse with the National Council of La Raza, an advocacy group.

Luis Osuna, the president of the lawyers association, said the group is not an advocacy group and supports candidates on both sides of the aisle. He said Trump’s attempts to discredit Curiel should give voters serious pause, not least because his comments reduce Hispanics in the legal profession to their heritage.

“Every time there is a comment like this, it is disheartening,” Osuna said. “It is not, unfortunately, surprising, given the source of the comments. But it displays a complete lack of understanding of the role that we have as attorneys and judges and the role that we have in upholding the Constitution.”

“He’s definitely using it as a dog whistle to his supporters,” he added. “Obviously, I don’t know what is in his heart. I can only judge based on the way he has acted in the past, but this has been a recurring theme in his campaign.”

Trump is not without recourse if he thinks that Curiel has engaged in misconduct. Russell Wheeler, a visiting fellow at the Brookings Institution, said Trump could file a complaint with the federal court of appeals. He said Trump would have to provide evidence that Curiel was biased in his behavior against the real estate mogul and could then proceed with a disqualification motion. Wheeler said Trump could also ask Curiel to recuse himself from the case because of a lack of impartiality. If Curiel declined, Trump could file an appeal.

But Wheeler added that, based on what he has seen, Curiel “has been nothing but fair in this case.”

As part of the ongoing class-action lawsuit against Trump University that he is overseeing, Curiel ordered the release of internal documents that showed Trump played a key role in the marketing for the business and how staff members were guided to push customers to purchase expensive follow-ups costing up to $35,000 after taking free introductory courses.

The order came in response to a request by The Washington Post, which argued that Trump’s presidential bid made the documents a matter of public interest. In the order, Curiel said that Trump had “placed the integrity of these court proceedings at issue.”

Robert Barnes contributed to this report.