U.S. District Judge Ann Donnelly issued the order Saturday evening after lawyers for the American Civil Liberties Union filed a court petition on behalf of people from seven predominantly Muslim nations who were detained at airports across the country as the ban took effect.
Cheers broke out in a crowd of demonstrators outside a Brooklyn courthouse as the decision, effective nationwide, was announced.
The order barred U.S. border agents from removing anyone who arrived in the U.S. with a valid visa from Iraq, Syria, Iran, Sudan, Libya, Somalia and Yemen.
It also covered anyone with an approved refugee application.
It was unclear how quickly the order might affect people in detention.
Copyright 2017 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.