A federal judge in Washington DC ruled Sunday that Ken Cuccinelli, the head of US Citizenship and Immigration Services, had not been lawfully appointed to his job and a policy directive speeding up initial screenings of immigrants seeking asylum during his tenure should be voided.

The decision comes months after Cuccinelli was initially tapped to lead USCIS by President Trump, a move that advocates immediately said violated a relatively obscure federal statute governing selections to agency positions. It’s the latest setback in the federal courts for the Trump administration and its efforts to restrict immigration.

The statute cited in Judge Randolph Moss’ decision — the Federal Vacancies Reform Act — allows the president to select certain senior officials to fill Cabinet and agency positions. At USCIS, Cuccinelli’s initial title was created by the administration: principal deputy director. Under the statute, the only way for Cuccinelli to have become eligible to be selected to lead the agency in an interim fashion was to be deemed a “first assistant.”

Moss said the creation of the title did not meet the necessary legal standard.

“On the merits, the Court concludes that Cuccinelli was not lawfully appointed to serve as acting Director and that, as a result, he lacked authority to issue the reduced-time-to-consult and prohibition-on-extensions directives,” Moss wrote.

The judge acknowledged that an "assistant" title can cover a range of duties, citing the iconic dispute from The Office about whether Dwight Schrute was assistant regional manager or assistant to the regional manager. But in either of those interpretations, the assistant was a subordinate, while Cuccinelli was leading USCIS, Moss said.

“Cuccinelli may have the title of Principal Deputy Director, and the Department of Homeland Security’s order of succession may designate the office of the Principal Deputy Director as the 'first assistant' to the Director. But labels — without any substance — cannot satisfy the FVRA’s default rule under any plausible reading of the statute.”

Because he wasn't legally appointed, Moss said a directive issued by Cuccinelli in July must be “set aside.” Asylum officers previously had to wait at least 48 hours after an immigrant had been detained for crossing into the US to interview them and hear their case. However, under the July directive issued by Cuccinelli, that window was reduced to one calendar day, according to a policy change released to staffers and obtained by BuzzFeed News. The new policy also made it so immigrants could not reschedule their interview unless there are extraordinary circumstances.

By Sunday evening, the ruling had already made an impact at USCIS. Senior officials at the agency emailed asylum officers across the country to let them know the directive instituted by Cuccinelli in July was "no longer operative." The consultation periods were to be extended back to at least 48 hours and the extensions would be reviewed on a case-by-case basis.

In an initial screening — called a credible fear interview — immigrants must prove there is a significant possibility that they have a well-founded fear of persecution in their home country. In the time before the interview in custody, immigrants consult with attorneys or others to help them prepare.

The ruling could mean the end of USCIS policies put forward by Cuccinelli, but it won’t have a broader impact on most recent actions by the Trump administration on immigration.

“It’s a significant ruling about the Federal Vacancies Reform Act, but one that may be limited in its broader impact. Although any directives signed only by Cuccinelli are now vulnerable to legal challenge, the ruling won’t affect other policies adopted by those higher on the food chain at DHS,” said Steven Vladeck, a professor at the University of Texas School of Law.

The lawsuit was filed by Democracy Forward, which advocates against unlawful activity by Trump and the executive branch.

"Today's ruling is a big win that confirms Ken Cuccinelli’s installation and service as acting director of USCIS was unlawful. This is both a victory for the rule of law and a significant blow to the Trump administration's xenophobic agenda,” the group's executive director Anne Harkavy said in a statement. "We are proud to share this legal victory with the brave asylum seekers who brought the Trump administration to court to ensure that the United States stays true to its tradition of providing a haven for those fleeing persecution and seeking asylum in America."

Cuccinelli has since moved on to becoming the second-in-command at DHS but is still listed as the senior official performing the duties of the director at USCIS. Last week, Acting DHS Secretary Chad Wolf selected Joseph Edlow to run USCIS’ day-to-day operations.

A DHS spokesperson said the agency disagreed with the ruling and would be looking closely at the decision.