SAN FRANCISCO (AP) — The U.S. Supreme Court ruling upholding President Donald Trump's travel ban may have a silver lining for people fighting other immigration policies after the court ruled that his prior comments about barring Muslims were not off-limits when evaluating the ban, legal experts said.

The remarks have been used to argue the ban was motivated by religious prejudice.

Trump — a prolific Twitter user— has also had his words turned against him in lawsuits over decisions to separate families at the border, end legal protections for young immigrants and revoke temporary status for people from particular countries.

Critics argue that judges should only evaluate the text of Trump's orders. 

Chief Justice John Roberts said Tuesday the Supreme Court "may look behind the face of the proclamation" barring travelers from five countries with overwhelmingly Muslim populations, though he adopted a relatively easy standard for the administration to justify its travel policy.

Allowing consideration of the president's statements is good news for plaintiffs in other immigration lawsuits against the administration, said Niels Frenzen, an immigration expert at the University of Southern California Gould School of Law.

"They could have said it's improper to consider any statements made on the campaign trail," he said. "That would have started to close the door in considering this outside evidence."

Still, Frenzen and other experts cautioned that the standard the Supreme Court adopted in its 5-4 ruling was highly deferential to the president.

"You're swimming upstream" if you're a plaintiff, said David Levine, a professor at the University of California, Hastings College of the Law.

The travel ban's stated goals of preventing entry to the U.S. of people who cannot be adequately vetted and inducing other countries to improve their security practices provided legitimate justifications, Roberts wrote.

Trump on Tuesday declared the ruling "a moment of profound vindication" following "months of hysterical commentary from the media and Democratic politicians who refuse to do what it takes to secure our border and our country."

Some civil liberties groups and immigration advocates likened the ruling to a 1944 Supreme Court decision upholding an executive order that required Americans of Japanese ancestry to be sent to detention camps.

In a scathing dissent, Justice Sonia Sotomayor said a "reasonable observer" would conclude the travel ban was motivated by "anti-Muslim animus." She accused her colleagues of "ignoring the facts, misconstruing our legal precedent, and turning a blind eye to the pain and suffering the proclamation inflicts upon countless families and individuals, many of whom are United States citizens."

The travel ban has been in place since December, when the justices stopped lower court decisions that had blocked part of it from being enforced. The policy applies to travelers from five countries with mostly Muslim populations — Iran, Libya, Somalia, Syria and Yemen.

It also blocks travelers from North Korea and some Venezuelan government officials and their families.

The Supreme Court ruling will likely prompt the administration to argue that courts should be just as deferential to the president's other immigration policies, so allowing the statements by Trump is not a complete victory for plaintiffs in other suits, said Stephen Yale-Loehr, a professor of immigration law practice at Cornell Law School.

"Plaintiffs will continue to try to bring the president's statements into their cases to show the discriminatory impetus," Yale-Loehr said. "But courts will continue to be deferential to the president."

A lawsuit filed in March cited Trump's vulgar language to describe African countries while claiming the administration's decision to end temporary protected status for some immigrants was motivated by racism.

In light of the Supreme Court's travel ban ruling, the U.S. judge overseeing the lawsuit, Edward Chen in San Francisco, issued an order Tuesday asking attorneys for both sides whether he should reconsider his decision allowing the racial animus claim to move forward.

Lawsuits over the Deferred Action for Childhood Arrivals program have cited Trump's statement referring to some Mexican immigrants as rapists as evidence that the decision to end it was motivated by prejudice against Mexicans.

Federal judges have blocked the DACA decision, with Judge Nicholas G. Garaufis in Brooklyn citing Trump's "racially charged language" in a ruling that allowed lawsuits over DACA to proceed.

A lawsuit filed Tuesday by New York, California and 15 other states also cites Trump's statement referring to Mexicans crossing the border as rapists as evidence that the border separation policy is consistent with what it calls Trump's demonstrated bias against Latin Americans.