Media playback is unsupported on your device Media caption Protesters shouted "let them in" at demonstrations at New York's JFK Airport

A US judge has issued a temporary halt to the deportation of visa holders or refugees stranded at airports after President Donald Trump issued an order barring entry to them for 90 days.

The American Civil Liberties Union (ACLU) filed a case in response to the order issued on Friday.

The White House said 109 people were detained, and around two dozen travellers are still being held.

Thousands of people gathered at US airports to protest against the move.

Mr Trump's executive order halted the entire US refugee programme and also instituted a 90-day travel ban for nationals from Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen.

Those who were already mid-flight were detained on arrival - even if they held valid US visas or other immigration permits.

Defending his move, Mr Trump early on Sunday tweeted: "Our country needs strong borders and extreme vetting, NOW." He told reporters on Saturday that the executive order was "working out very nicely. You see it at the airports, you see it all over".

His Chief of Staff Reince Priebus denied that the introduction of the ban had been chaotic. He said that, of the 325,000 people entering the US on Saturday, 109 were detained.

"Most of those people were moved out," he told NBC's Meet the Press programme. "We've got a couple of dozen more than remain and I would suspect that as long as they're not awful people that they will move through before another half a day today."

'Irreparable injury'

The ruling from federal Judge Ann Donnelly, in New York, prevented the removal from the US of people with approved refugee applications, valid visas, and "other individuals... legally authorised to enter the United States".

The emergency ruling also said there was a risk of "substantial and irreparable injury" to those affected.

Her ruling is not on the constitutionality of Mr Trump's executive order.

Media playback is unsupported on your device Media caption US immigration order: Families split as Trump ban enforced

The department of homeland security said it would continue to enforce the measures.

Fear, uncertainty and small acts of rebellion at Dulles airport

Image caption Lawyers gathered to represent those facing travel bans

Ali worked for three years as an interpreter for the US Army and gained admittance to the US through a Special Immigrant Visa, reserved for Iraqi and Afghan nationals who face threats of violence for working for Americans during the conflicts there.

He now has a green card, and returned to Iraq for his father's funeral, only to be delayed for hours for questioning at Dulles.

"We are not terrorists. We are not bad people," said Ali. "It's so hard. I hope they will change their minds on this position."

Read more from the BBC's Jessica Lussenhop on the night at Dulles airport, near Washington in Virginia

The court case was brought early on Saturday on behalf of two Iraqi men detained at JFK Airport in New York. One worked for the US military in Iraq, while the other is married to a former US military contract employee.

Both have now been released. Another court hearing is set for February.

Image copyright Twitter / ACLU Image caption The American Civil Liberties Union (ACLU) tweeted the outcome of the ruling

Lee Gelernt, deputy legal director of the Immigrants Rights Project, who argued the case in court said that some people had been threatened with being "put back on a plane" later on Saturday.

Mr Gelernt also said the judge had ordered the government to provide a list of names of those detained under the order.

Judges elsewhere in the US have also ruled on the issue:

In Boston, a judge decided two Iranian nationals, professors at the University of Massachusetts, should be released from detention at Logan International Airport

An order issued in Virginia banned, for seven days, the deportation of green card holders held at Dulles Airport and ordered the authorities to allow access to lawyers

A Seattle judge issued an emergency stay of removal from the US for two people

Media playback is unsupported on your device Media caption President Trump: "It's not a Muslim ban, but we're totally prepared"

Criticism of Mr Trump's decision has been growing louder outside the US.

Iran and Iraq are threatening a reciprocal ban on US citizens entering the country.

Chancellor Angela Merkel of Germany said "even the necessary, determined fight against terrorism does not justify placing people of a certain origin or belief under general suspicion".

Canadian Prime Minister Justin Trudeau tweeted that his government remained committed to welcoming "those fleeing persecution, terror and war".

A spokesperson for UK PM Theresa May said she "did not agree" with the restrictions, and French independent presidential candidate Emmanuel Macron tweeted: "I stand with the people fleeing war and persecution".