A federal court here blocked part of US President Donald Trump's immigration order banning citizens from seven Muslim majority countries from entering the US.
The Brooklyn District Court came to the aid of scores of refugees and others who were trapped at airports across the US on Saturday after an "extreme vetting" by Trump which bans citizens from Iran, Iraq, Syria, Somalia, Sudan, Libya and Yemen from entering the country.
Judge Ann M Donnelly on Saturday prevented the government from deporting some arrivals who found themselves ensnared by the executive order.
The order stopped short of letting the already arrived people into the country or issuing a broader ruling on the constitutionality of Trump's actions, the New York Times reported.
The judge nominated by former President Barack Obama ruled that sending back the travellers to their homelands would cause them "irreparable harm".
The case played out amid global turmoil as the order signed on Friday shut the borders of the US for an Iranian scientist headed to a lab in Massachusetts, a Syrian refugee family headed to a new life in Ohio and countless others across the world.
It also suspended entry of all refugees to the US for 120 days and barred Syrian refugees indefinitely.
The Department of Homeland Security said the order also barred green card holders from those countries from re-entering the US.
The White House said green card holders from the seven affected countries who are outside the US would need a case-by-case waiver to return.
Trump has been accused of constitutional and legal overreach by two Iraqi immigrants, defended by the American Civil Liberties Union (ACLU).
Meanwhile, large crowds of protesters turned out at airports around the country to denounce the new President's ban, The New York times reported.
According to lawyers for ACLU, who sued the government to block the order, about 100 to 200 people were detained upon arrival at American airports.
Hundreds of people waited outside of the courthouse chanting, "Set them free!" as lawyers made their case.
"We've gotten reports of people being detained all over the country," said Becca Heller, director of the International Refugee Assistance Project. "They're literally pouring in by the minute."
Trump earlier on Saturday said: "It's not a Muslim ban, but we were totally prepared."
"It's working out very nicely. You see it at the airports, you see it all over."
There were numerous reports of students attending American universities who were blocked from returning to the US from visits abroad.
Legal residents who have a green card and are currently in the US should meet a consular officer before leaving the country, a White House official said.
A Stanford student, Nisrin Omer, a legal permanent resident, said she was held at the Kennedy International Airport here for about five hours but was eventually allowed to leave the airport.
Others who were detained appeared to be still in custody or sent back to their home countries, she said.