THE president’s plan to ban travel from six Muslim-majority countries, the Fourth Circuit Court of Appeals said on May 25th, “drips with religious intolerance, animus and discrimination”. By a 10-3 vote, the appeals court based in Richmond rebuffed Donald Trump’s attempt to have his second try at a travel ban reinstated after it was blocked by a Maryland judge in mid-March. The pause on the entry of refugees, and on travellers from Iran, Libya, Somalia, Sudan, Syria and Yemen, “speaks with vague words of national security” and dials back some of the more egregious aspects of the first ban, the court ruled, but abandons “one of our most cherished founding principles—that government shall not establish any religious orthodoxy, or favour or disfavour one religion over another”.

The centrepiece of the 67-page majority opinion, written by the court’s chief judge, Roger Gregory, is a traipse through a 17-month-long string of declarations, tweets and comments from the president and his advisers which reveal the true motive behind the travel restrictions. The story begins with Mr Trump’s campaign-trail call, in December 2015, for a “total and complete shutdown” on Muslims entering America. It wends its way to the following summer, when Mr Trump appeared on NBC’s “Meet the Press” in July 2016. Judge Gregory recounts that when Mr Trump was asked “whether he had ‘pulled back’ on his ‘Muslim ban’,” Mr Trump replied, “I actually don’t think it’s a rollback. In fact, you could say it’s an expansion. I’m looking now at territories. People were so upset when I used the word Muslim. Oh, you can’t use the word Muslim. Remember this. And I’m okay with that, because I’m talking territory instead of Muslim.” In another flourish foreshadowing the trouble his eventual order would face in court, Mr Trump added: “Our constitution is great...Now, we have a religious, you know, everybody wants to be protected. And that’s great. And that’s the wonderful part of our constitution. I view it differently.”

Mr Trump’s rather novel sense of what the constitution permits is, in the eyes of Judge Gregory and nine of his colleagues—all picked by Democratic presidents—persuasive evidence that his executive order is irreparably tainted. That’s true despite Kleindienst v Mandel, a 1972 Supreme Court ruling that permits presidents to stop foreigners from entering the country and instructs courts not to “look behind the exercise of that discretion” by investigating its motive. But according to Justice Anthony Kennedy's controlling opinion in Kerry v Din,a 2015 case clarifying Mandel, in the absence of a “bona fide” reason to bar entry, judges should take a second look.

The Fourth Circuit majority found that Mr Trump’s thin and weakly reasoned national-security justification for restricting travel from the six Muslim countries did not suffice as a good-faith reason. Drawing on an amicus brief Joshua Matz wrote on behalf of several dozen constitutional-law scholars, Judge Gregory concluded “there is simply too much evidence that [the order] was motivated by religious animus for it to survive any measure of constitutional review”. In a key concurring opinion, Judge Stephanie Thacker agreed that hostility against Muslims fuelled the ban but argued that campaign statements should be out of bounds, as they “are inevitably scatted with bold promises”. Post-inauguration musings from “the president, his adviser and the text” of the first executive order, she wrote, are quite enough to make “crystal clear a primary purpose of disfavouring Islam and promoting Christianity”.

Three dissenting judges—all appointed by Republican presidents—saw International Refugee Assistance Project v Trump quite differently. Judge G. Steven Agee denied that the plaintiffs had standing to sue. Judge Paul Niemeyer wrote the majority had “radically extend[ed] Supreme Court establishment-clause precedents” to reach a “politically desired outcome”. And Judge Dennis Shedd argued that “the real losers in this case” are “the millions of individual Americans whose security is threatened on a daily basis by those who seek to do us harm”.

What happens next? Jeff Sessions, the attorney-general, quickly announced that the administration “will seek review of this case in the United States Supreme Court”. What type of review is still unclear. The government could ask the nine justices for an immediate emergency order to temporarily lift the stay on the travel ban, a request that would require five votes and a sense that waiting to implement the ban may bring irreparable harm. The other tack would be to ask the justices to hear their appeal in the usual course. The latter path is slower but possibly surer, as it takes only four votes to hear a case. But the appeal would not be heard until October at the earliest, and a decision would take months, diluting the urgency of the administration’s claims. The Trump administration could also pursue both strategies simultaneously.

A host of questions arise regarding how the ideologically divided Supreme Court, with a 5-justice conservative majority, will view Mr Trump’s besieged ban—and even whether they will agree to review it. One unknown is how Justice Kennedy, the unpredictable swing justice, will handle the controversy. Another is the chief justice, John Roberts, a conservative who laments his court’s politicisation and cannot relish the prospect of having to adjudicate such tension between the branches of government.