Those who were already mid-flight were detained on arrival – even if they held valid US visas or other immigration permits. It is not known how many others were turned away at airports overseas as they tried to board flights to the US.

Thousands gathered at airports around the country to protest on Saturday, including lawyers who offered their services for free to those affected.

Further demonstrations were held on Sunday, including protests outside the White House and Trump Tower in New York.

Who is affected by the ban?

As well as the ban on all refugees, travellers who have nationality or dual nationality of Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen are not permitted to enter the US for 90 days, or be issued an immigrant or non-immigrant visa.

This includes those who share dual nationality with allied countries, including the UK, although Canada has been told its dual nationals are not affected.

But there remains much confusion.

The UK foreign office put out a statement saying that only those dual nationals travelling from one of the blacklisted seven countries would be subject to extra checks – those travelling between the UK and US would not be affected.

However, one Scottish veterinary student – who travels on an Iranian passport – was unable to fly home from her holiday in Costa Rica because she was told her transit visa for the US was no longer valid.

White House Chief of Staff Reince Priebus said US green-card holders – legal residents – would also not be affected, but some have been detained since the order came into effect.

What does the White House say?

Mr Trump tweeted early on Sunday that the US needed “extreme vetting, NOW” but later, in a statement, tried to offer more reassuring words, saying: “This is not about religion – this is about terror and keeping our country safe.

“We will again be issuing visas to all countries once we are sure we have reviewed and implemented the most secure policies over the next 90 days,” he said.

Mr Priebus rejected criticism that the implementation of the order had been chaotic, and said only 109 people, out of 325,000 travelling, had been detained and “most of those people were moved out”.

“We’ve got a couple of dozen more that 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,” he told US media on Sunday.

But they have failed to allay concern among some in their Republican party. The Republican chair of the US Senate Foreign Relations committee, Senator Bob Corker, said the executive order had been “poorly implemented”, particularly for green-card holders, and the “administration should make appropriate revisions”.

Democratic Senate Minority leader Chuck Schumer said the US now appeared “less humanitarian, less safe, less American” and said the Democrats would introduce legislation to overturn it.

Legal minds have their say

In a joint statement, 16 attorneys general, from states including California, New York and Pennsylvania, said they would “use all of the tools of our offices to fight this unconstitutional order” and, until it was struck down, would “work to ensure that as few people as possible suffer from the chaotic situation that it has created”.

Late on Saturday, federal Judge Ann Donnelly, in New York, ruled against the removal from the US of people with approved refugee applications, valid visas, and “other individuals… legally authorised to enter the United States”.

She was ruling on a case brought on behalf of two Iraqi men with links to the US military who were detained at JFK Airport in New York, who were later released.

Elsewhere in the US:

 In Boston, a judge decided two Iranian nationals, both university professors, 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

The Department of Homeland Security has said it will continue to enforce the measures.

Countries react with alarm

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

Canada is offering temporary residence to those stranded there because of the US order, the immigration minister said. Prime Minister Justin Trudeau earlier tweeted that Canada welcomed “those fleeing persecution, terror and war”.

Iran is threatening a reciprocal ban on US citizens entering the country. Similar comments came out of Iraq, with whom the US is working to drive IS out of Mosul.

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”.

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.”