CNN  — 

Less than a month ago, the Supreme Court ruled in favor of a Christian baker who refused to make a cake for a gay couple’s wedding, saying a state commission’s ruling against him was rooted in anti-religious hostility.

On Tuesday, in upholding President Donald Trump’s travel ban, five Supreme Court justices ruled that his critical statements about Islam and Muslims, both as a candidate and as chief executive, don’t matter.

Outside the Supreme Court on Tuesday, protesters and members of Congress accused the justices of adopting a double standard: one set of rules for white Christians and another for Muslims and other religious minorities.

“It’s an obvious contradiction,” said Rep. André Carson of Indiana, a Democrat who’s one of two Muslims in Congress. “It’s absolutely apparent that there is a double standard.”

In a sharply worded dissent, Justice Sonia Sotomayor said the high court’s decision on Trump’s travel ban sends precisely that message.

“Unlike in Masterpiece, where the majority considered the state commissioners’ statements about religion to be persuasive evidence of unconstitutional government action,” Sotomayor wrote, referring to the Christian baker’s shop, Masterpiece Cakeshop, “the majority here completely sets aside the President’s charged statements about Muslims as irrelevant.”

“That holding erodes the foundational principles of religious tolerance that the court elsewhere has so emphatically protected, and it tells members of minority religions in our country that they are outsiders, ‘not full members of the political community,’ ” Sotomayor added.

In the Masterpiece case, Justice Anthony Kennedy, who wrote the majority decision, said members of the Colorado Civil Rights Commission “showed elements of a clear and impermissible hostility” toward the religious beliefs of Jack Phillips, the baker.

At public hearings, some commissioners “endorsed the view that religious beliefs cannot legitimately be carried into the public sphere or commercial domain,” “disparaged Phillips’ faith as despicable and characterized it as merely rhetorical, and compared his invocation of his sincerely held religious beliefs to defenses of slavery and the Holocaust,” Kennedy wrote.

What Trump has said about Islam is arguably worse, said several Muslim groups and legal experts.

“In the Masterpiece Cakeshop case, the court actually went out of its way to rest its decision on the anti-religious comments of a local official, when that issue wasn’t even presented before the judges at the briefing,” said Farhana Khera, executive director of Muslim Advocates.

“Here, in contrast, the court went out of its way to ignore the copious amounts of anti-Muslim bigotry from the President as he was developing and then enacting the policy. It’s a total double standard,” Khera added.

Trump’s remarks on Islam demonstrate the travel ban’s true intent, Sotomayor wrote. He has said “Islam hates us,” has told apocryphal stories about generals who shoot Muslims with bullets dipped in pigs’ blood and has called for a “complete and total shutdown of Muslims entering the United States.”

That policy, Sotomayor said, morphed into an executive order “putatively based on national-security concerns.”

“But this new window dressing cannot conceal an unassailable fact: the words of the President and his advisers create the strong perception that the Proclamation is contaminated by impermissible discriminatory animus against Islam and its followers.”

But there are important differences between the Masterpiece Cakeshop case and the legal dispute over Trump’s travel ban, said Ira C. Lupu, an expert on religion and constitutional law at George Washington University in the nation’s capital.

“It is a double standard,” Lupu said, “and it is justified to a point.”

The travel ban case was primarily about the separation of powers, Lupu said. That is, whether one branch of the federal government, the Supreme Court, could constrain or even overrule another branch, the executive.

The case is also about national security and how our country relates to foreign ones. In a footnote, Chief Justice John Roberts suggests it may not be appropriate to apply the Constitution’s establishment clause, which prohibits the government from favoring a particular religion, to national security issues and foreign affairs.

“The issue … is not whether to denounce the President’s statements, but the significance of those statements in reviewing a Presidential directive, neutral on its face, addressing a matter within the core of executive responsibility,” Roberts wrote.

The text of the executive order itself, the chief justice said, exhibits no evidence of anti-Muslim animus. “The text says nothing about religion,” he said.

Justice Clarence Thomas, who concurred with the majority on Tuesday, wrote a separate opinion flatly stating that “the plaintiffs’ proffered evidence of anti-Muslim discrimination is unpersuasive.”

Notably, Roberts mentions but doesn’t defend Trump’s comments on Islam, or explain why they were not considered as evidence that the travel ban was motivated by anti-Muslim hostility.

“He doesn’t have to,” Lupu said. “He got his five votes, and he would only get into a mess if he started dealing with those comments.”

‘An anxious world’

Kennedy sided with the majority in upholding Trump’s travel ban. But he also wrote a concurring opinion urging politicians to be careful when they talk about religion and religious freedom.

“There are numerous instances in which the statements and actions of Government officials are not subject to judicial scrutiny or intervention,” Kennedy wrote. “That does not mean those officials are free to disregard the Constitution and the rights it proclaims and protects.”

“The First Amendment prohibits the establishment of religion and promises the free exercise of religion,” Kennedy continued. “An anxious world must know that our Government remains committed always to the liberties the Constitution seeks to preserve and protect, so that freedom extends outward, and lasts.”

During oral arguments, Kennedy demonstrated a keen concern about whether anti-religious animus lurked behind the travel ban.

“Suppose you have a local mayor, and as a candidate he makes hateful statements. He’s elected, and on day two he takes acts that are consistent with those hateful statements. That’s – whatever he said in the campaign is irrelevant?” Kennedy asked at the time.

Sotomayor argued that there’s more to the case than Trump’s campaign rhetoric. He has also made numerous statements about the travel ban since his election

“The President’s statements, which the majority utterly fails to address in its legal analysis, strongly support the conclusion that the Proclamation was issued to express hostility toward Muslims and exclude them from the country,” Sotomayor said.

“Given the overwhelming record evidence of anti-Muslim animus, it simply cannot be said that the Proclamation has a legitimate basis.”

CNN’s Ariane De Vogue contributed to this report.