Carlos Barria / Reuters

President Trump suffered a series of major setbacks last week, beginning with FBI Director James Comey’s blockbuster announcement that his agency is investigating the Trump campaign’s ties to Russia and ending with the collapse of the Republican effort to repeal the Affordable Care Act. But he also closed out the week with a little-noticed victory in the courts—one that could herald a path forward on one of his most contentious policies.

The case, Sarsour v. Trump, was filed in a federal district court in Alexandria, Virginia, just outside of Washington, D.C. Linda Sarsour, a Palestinian American activist who most recently helped organize the Women’s March, and a group of other Muslim plaintiffs asked the court to suspend the second version of his controversial travel ban. The executive order temporarily barred visa travel from six Muslim-majority countries and suspended the U.S. Refugee Admissions Program for four months.

Their petition made two statutory complaints: that the order broke a non-discrimination provision in federal immigration law for immigrant visas, and that it broke certain federal administrative rules. They also fought the order on constitutional grounds, arguing it violated the First Amendment’s religious-freedom protections and the Fourteenth Amendment’s Equal Protection Clause.

To obtain an injunction that would halt the ban’s implementation, the plaintiffs had to prove to Judge Anthony Trenga that they’d likely succeed on the merits of their case when it went to trial—in other words, that their case was reasonable enough to potentially sway a jury. On Friday, Trenga ruled against them on all four counts. He dispatched the administrative-law complaint easily: The office of the presidency isn’t an “agency” under the Administrative Procedures Act, he wrote, so it wasn’t an issue in this case. For the other three arguments, Trenga laid out a more complete rationale against them.

In practical terms, the decision wasn’t a decisive victory, though it may have soothed the Trump administration after a tumultuous week. Trenga’s ruling doesn’t affect the other half-dozen cases on Trump’s travel ban working their way through federal courts, including the Hawaii case that led to another nationwide injunction earlier this month. But it’s a significant win nonetheless: By siding with the president on one of the most high-profile legal battles in recent years, Trenga’s decision offered a template for other courts to follow if they choose—including, perhaps, the U.S. Supreme Court.

Central to the dispute are two clauses of the Immigration and Naturalization Act, or INA. In arguing for the second travel ban earlier this month, the Justice Department cited a section of the INA allowing the president to “suspend the entry of all aliens or any class of aliens as immigrants or nonimmigrants, or impose on the entry of aliens any restrictions he may deem to be appropriate.” This provision, known as Section 1182(f), is the legal mechanism Trump used to suspend visa applications for 90 days and the U.S. Refugee Admissions Program for 120 days.

That law seems fairly clear-cut in the government’s favor. But Sarsour and her fellow plaintiffs pointed to a 1965 amendment to the INA that says “no person shall receive any preference or priority or be discriminated against in the issuance of an immigrant visa because of his race, sex, nationality, place of birth, or place of residence.” Because that amendment came after the 1952 provision, the plaintiffs argued, it restricts Trump’s ability to suspend visa applications on those grounds when enforcing Section 1182(f).

Trenga disagreed. His reading of the act depicts two distinct events: the visa-application process, which is covered by the 1965 amendment, and a foreign national’s physical entry into the United States, which can be constrained by the president through Section 1182(f). Even if the amendment covered the same process as Section 1182(f), Trenga noted, it would only protect immigrant visas. That would leave a broad swath of non-immigrant foreign nationals still barred from traveling to the United States by Trump’s invocation of 1182(f).

“In determining how to proceed, the court is cast upon cross jurisprudential currents,” Trenga said. On one hand is Lemon v. Kurtzman, a landmark Supreme Court case that laid out a three-prong test for courts to determine whether a government act violates the First Amendment’s religious-freedom protections. One of those prongs says that the act must have a “secular legislative purpose” or else it won’t survive judicial review.

On this point, Sarsour and the other plaintiffs offered evidence to allege Trump was operating in bad faith—that his ban was designed to restrict only Muslims from entering the United States and didn’t have any other aim. Their submissions included his original call for a “total and complete shutdown of Muslims entering the United States” in December 2015, a TV interview in which former New York City Mayor Rudy Giuliani said Trump approached him about a “Muslim ban” and “the right way to do it legally,” and top Trump adviser Stephen Miller’s assertion that the revised order was “going to have the same basic policy outcome for the country.”

But Trenga also had to consider a separate set of Supreme Court precedents, specifically on the federal government’s immigration powers. Under a series of cases starting with Kleindienst v. Mandel, the Supreme Court said the president need only offer a “facially legitimate and bona fide rationale” to survive a court’s scrutiny. Translation: The federal government has exceptionally broad latitude to craft immigration policies, so long as they can offer a seemingly plausible reason for them.

As broad as it may be, that standard wasn’t necessarily damning for Sarsour and the other plaintiffs. My colleague Garrett Epps noted last week that even under the lenient Mandel standard, Trump’s long history of controversial comments about Muslims could still prevent the ban from passing constitutional muster. But the judge sided with the federal government instead, citing the revisions made between the first and second executive orders.

Such a conclusion is no accident, since the Trump administration consciously designed the second order to satisfy the courts’ concerns about the first one. The White House kept the 120-day suspension of the U.S. Refugee Assistance Program, but nixed both the permanent ban on Syrian-refugee resettlement and the exemption for religious minorities. Iraq was removed from the list of countries affected by the visa-application ban, and already issued visas would not be suspended. The administration also included a series of exemptions to the visa-application ban giving consular officials broad latitude to override it when they deemed it necessary.

Those revisions, the judge concluded, reconfigured the calculus behind the court’s judgment. Trump’s past statements about Muslims still mattered, but they were no longer coupled with a “facially discriminatory order.” That presented a potential separation-of-powers problem: If the court ruled his remarks still compromised a neutrally drafted order, it would have “effectively disqualified him from exercising his lawful presidential authority” under federal immigration law.

For Trenga, that would have been a step too far. Accordingly, he wrote, it was “no longer likely that plaintiffs can succeed on their claim that the predominate purpose of [the second executive order, or EO-2] is to discriminate against Muslims based on their religion and that EO-2 is a pretext or a sham for that purpose.” Other judges in other courts may continue to rule differently. But with his ruling, Trenga has supplied them with a way to uphold the president’s ban.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.