AMERICA, along with its new president, is getting a crash course in the role of the federal judiciary. On February 3rd, one week after Donald Trump issued an executive order banning travel from seven Muslim-majority countries and suspending America’s refugee programme, a federal district court in Seattle temporarily halted Mr Trump’s plan. Judge James Robart said there is “no support” for the government’s argument that the ban made America safer. Four days later, at least two members of a three-judge panel on the 9th Circuit Court of Appeals seemed unimpressed when the government challenged Mr Robart’s ruling. For now, America remains open to permanent residents, visa-holders and refugees seeking its shores—and Mr Trump must grapple with the unfamiliar feeling of not getting his way.

The battle over the stymied plan—which the White House insists is wholly different from the “total and complete shutdown of Muslims entering the United States” that Mr Trump first announced on the campaign trail in December 2015—proceeds on two parallel tracks. In the courts, judges and lawyers wrangle over an array of legal questions involving constitutional provisions, congressional statutes and the doctrine of legal standing. Meanwhile on Twitter, the president is undermining support for the process. After Mr Robart stopped the 45th president’s executive order in its tracks, Mr Trump tweeted: “When a country is no longer able to say who can, and who cannot, come in & out, especially for reasons of safety & security—big trouble!” In a follow-up missive, he went one step further: “The opinion of this so-called judge…is ridiculous and will be overturned!” Some conservatives who oppose Mr Trump worry about the damage he could do to the country’s governing institutions and customs. This is an early test.

So far, the courts have performed their usual role. The judiciary has often checked presidential authority in foreign affairs, security and immigration, notes Mark Peterson of UCLA. Immigration is the area “most prone to such a judicial role”, he says. While the White House is correct to note that Article II of the constitution and the Immigration and Nationality Act of 1952 grants the president wide discretion in immigration enforcement, amendments to the law in 1965 preclude restrictions on the basis of an individual’s national origin, race and other such broad categories. The text of Mr Trump’s executive order may not be cast in explicitly religious terms, but public statements by both him and his allies leave little doubt that it is rooted in a suspicion of Muslims. In the hearing before the 9th Circuit on February 7th in Washington v Trump, these comments proved a liability for the government.

August Flentje, the lawyer for the president, argued that Mr Robart’s ruling had upset the balance the Trump administration had struck between “welcoming people into our country” and “making sure our country is secure”. That balancing is the task of the political branches, he said, not the courts. But when repeatedly pressed to cite evidence showing that visitors from the seven countries covered by the ban—Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen—posed an actual risk of terrorism to America, Mr Flentje had little to offer. Merely mentioning that the Obama administration considered the countries to be terror-prone, one judge complained, is “pretty abstract” and justifies a visa requirement, not an all-out ban.

Facing steady resistance from the panel, and remarking, “I’m not sure I’m convincing the court”, Mr Flentje punted. He asked the judges to at least consider lifting Mr Robart’s restraining order with regard to people who have never been to America. There is no good reason, Mr Flentje implied, to give every foreign national from those seven countries free rein to visit. This last-ditch argument—that Mr Robart’s move went too far and covered too much—was Mr Flentje’s best. In response, Noah Purcell, the lawyer for Washington state, noted two reasons why the travel ban should remain suspended in its entirety. Targeting Muslims violates the First Amendment rule against religious establishments, he said. And the interests of America’s legal residents are harmed when their relatives in the Middle East and Africa are banned from visiting them.

This is how the boundaries of presidential authority are gradually discovered. If Mr Trump loses his appeal in the 9th Circuit, the government will ask the Supreme Court to weigh in. Given the four-four ideological split there, the on-again, off-again travel rules may remain in limbo for a while. The next test will come if this ends with a ruling against the administration. All presidents encounter resistance from judges, but only Andrew Jackson challenged the authority of the courts, says Mr Peterson (Mr Trump has returned Jackson’s portrait to the Oval Office). That confrontation changed America: Jackson’s presidency saw the spread of judicial elections, to bring the judges into line with the wishes of voters. Whatever the outcome of Washington v Trump, the president will leave his stamp on the courts. As well as picking a new Supreme Court justice, he will soon set about filling over 100 vacancies in the nation’s district and appellate courts.