A federal judge in Brooklyn blocked part of President Donald Trump’s executive order banning citizens of seven predominantly Muslim countries from entering United States in an emergency hearing. A Yale Law School team, working around the clock over the weekend, played a significant role in convincing the judge.

Early Saturday morning, the Worker and Immigrant Rights Advocacy Clinic at the Law School — which represents immigrants and low-wage workers in a variety of cases — joined the nation’s leading civil rights groups in filing the first legal challenge to the Trump administration on behalf of two Iraqi refugees detained at New York City’s John F. Kennedy International Airport. Judge Ann Donnelly of the District Court for the Eastern District of New York ruled in their favor, issuing a temporary stay at the national level on Saturday night. The ruling came as large crowds of protesters flocked to major airports to denounce Trump’s ban while lawyers across the country came to the aid of the detained immigrants.

“The executive order is blatantly unconstitutional, motivated by naked discrimination, based on national origin and religious affiliation,” said former Law School Dean Harold Koh, who served as Legal Adviser of the Department of State for four years under the Obama administration. “As a former government national security lawyer, I see no rational national security basis for such wildly overbroad immigration restrictions.”

“The reported lack of interagency legal vetting of the order only further proves that the order was driven by rank prejudice, not valid governmental needs,” Koh added.

The plaintiffs, Hameed Khalid Darweesh and Haider Sameer Abdulkhaleq Alshawi, were detained at JFK airport last Friday despite valid travel documentation. According to the petition the Law School team drafted, they were targeted by terrorists back home for their connection with the U.S. Darweesh’s work for the U.S. government put him “in substantial risk of being targeted, attacked and killed by anti-American militias and insurgents” while Alshawi was thought by insurgents in Baghdad to be a collaborator, due to his family’s ties to the U.S. military.

Within hours of the executive order’s Friday afternoon passage, about 30 faculty and students at the Law School clinic have been working nonstop to draft petitions, motion for class certification and seek emergency stay for their clients, which Donnelly granted swiftly after the Saturday hearing. The team, in coalition with American Civil Liberties Union and other civil rights groups, argued that stopping the plaintiffs and other similarly situated individuals from entering the U.S. would violate the clause of due process and equal protection of the Fifth Amendment, as well as international and immigration law.

In her ruling, Donnelly, an appointee of former President Barack Obama, pointed out the “irreparable harm” the removal of the stay would inflict upon the refugees. The two Iraqi men were both released from custody before the ruling. Advocates estimated that 100 to 200 people detained upon arrival in U.S. airports would benefit from the ruling.

“Today through advocacy both from lawyers and protesters on the ground, a lot of problems start to dissipate; but they are not gone,” Will Bloom LAW ’17, an intern at Jerome N. Frank Legal Services Organization, the umbrella organization of WIRAC, said. He added that reports of U.S. Customs and Border Protection coercing immigrants to forgo their rights to remain in the country and people being put on planes against their wills kept coming in.

The initial suit focused primarily on people who are already in the U.S. or who are in transit when the order was announced. Bloom said the order targeted the group of people with the most risk of being sent back or coerced to give up their authorization. After the initial victory, the team proceeded to work to ensure that the ruling is obeyed on the ground and to question the constitutionality of Trump’s executive order.

“This is the first step in litigation,” Bloom said. “There’s likely to be more executive actions. From what we’ve been seeing from the administration it’s not clear what the administration’s going to do but we’re going to be ready for whatever it is.”

Melissa Marichal LAW ’18, another student intern at the LSO, said the group saw the case as a continuation of the clinic’s work to protect the civil and constitutional rights of immigrant communities.

Marichal added that she and her teammates are taking shifts to ensure that at least one student is available at all times to respond to any reports of noncompliance. Bloom said he had been getting minimal sleep but all of the team members, who have been up late editing motions, are “tired but energized.”

The White House maintained on Sunday that the ruling does not undercut the executive order, but scaled back on the ban late Sunday to allow people holding green cards from the affected countries to return to the U.S.

David Yaffe-Bellany contributed reporting.

Correction, Jan. 30: An earlier version of this article misstated the time at which Hameed Khalid Darweesh and Haider Sameer Abdulkhaleq Alshawi were released relative to the judge’s ruling.