NEW YORK - A federal judge in New York has issued an emergency stay temporarily halting the removal of individuals detained after President Donald Trump issued an order to ban immigrants from seven Muslim-majority countries from entering the United States.

The move appears to mark the first successful legal challenge to the Trump administration and affects those who have arrived in the US with previously approved refugee applications or were in transit with valid visas.

“I hope Trump enjoys losing. He’s going to lose so much we’re going to get sick and tired of his losing,” ACLU national political director Faiz Shakir said shortly after the decision was announced.

The White House did not immediately respond to a request for comment about the court ruling.

US District Court Judge Ann Donnelly ruled on Saturday in favour of a habeas corpus petition filed by the American Civil Liberties Union (ACLU) on behalf of two Iraqi men who were detained at John F Kennedy International Airport on Friday after Trump signed his order.

Donnelly, who was nominated by former President Barack Obama and confirmed to her judgeship in 2015, ruled in the Eastern District of New York that “There is imminent danger that, absent the stay of removal, there will be substantial and irreparable injury to refugees, visa holders, and other individuals from nations subject to the January 27, 2017 executive order.”

Shakir said the stay will affect those who are “currently detained in airports” and that the ACLU’s lawyers “will continue litigating the rest of the people impacted” by the order“.

This ruling preserves the status quo and ensures that people who have been granted permission to be in this country are not illegally removed off US soil," Lee Gelernt, deputy director of the ACLU’s Immigrants’ Rights Project, said.

The ruling deals with a portion of Trump's order handed down Friday, which bars Syrian refugees indefinitely and halts the resettlement of all refugees for four months as the administration reviews the vetting process.

The order also denies entry for 90 days for individuals from seven predominantly Muslims countries: Iraq, Iran, Somalia, Sudan, Syria, Libya and Yemen.

“Clearly the judge understood the possibility for irreparable harm to hundreds of immigrants and lawful visitors to this country," ACLU Executive Director Anthony Romero said in a statement.

"Our courts today worked as they should as bulwarks against government abuse or unconstitutional policies and orders. On week one, Donald Trump suffered his first loss in court.”

The order Saturday evening capped off a chaotic first day following Trump's directive, as the administration moved to implement his order, with reports emerging of individuals being detained at a number of airports across the country.

The Department of Homeland Security said Trump's order would apply to green card holders from the seven impacted countries.

"President Trump and his administration are right to be concerned about national security, but it’s unacceptable when even legal permanent residents are being detained or turned away at airports and ports of entry," Republican Senator Jeff Flake said in a statement.

A senior administration official said green card holders from the countries who are currently outside the US will need a case-by-case waiver to return to the US and green card holders in the US would need to meet with a consular officer before leaving the country.

An administration official also said that Trump advisers had been in contact with the State Department and Department of Homeland Security for weeks prior to the issuing of his Friday order, arguing it affected a "relatively small" number of people.

"It’s important to keep in mind that no person living or residing overseas has a right to entry to the US," the official said.

But backlash on Saturday to the order was swift from civil-rights groups, businesses and various Democratic officials, which condemned it as a departure from the US tradition of accepting refugees and comparing it to Trump's campaign proposal to temporarily ban Muslim migrants.

Democratic Congresswoman Nydia Velázquez slammed Trump’s executive order outside JFK where she and fellow Congressman Jerrold Nadle worked to secure release of the two Iraqi men, calling it “arbitrary” and “unjust.”

Democrats also pressed the Trump administration for further explanation on the order, with Senate Minority Leader Charles Schumer called on the Department of Homeland Security to immediate "rescind" it.

"It's not a Muslim ban, but we are totally prepared," Trump told media gathered in the Oval Office on Saturday afternoon as he signed three new executive orders on lobbying, a plan to defeat the Islamic State in Iraq and Syria (ISIS) and a reorganisation of the National Security Council.

"It's working out very nicely. You see it in the airports, you see it all over. It's working out very nicely and we are going to have a very, very strict ban and we are going to have extreme vetting, which we should have had in this country for many years," Trump said.



AFP adds: Prime Minister Justin Trudeau welcomed Canadian immigrants in a sunny Twitter message written in stark contrast to Trump's order temporarily banning all refugees and many Muslims from travelling to the United States.

"To those fleeing persecution, terror & war, Canadians will welcome you, regardless of your faith. Diversity is our strength #WelcomeToCanada," Trudeau posted on Twitter.