U.S. President Donald Trump's order to restrict people from seven Muslim-majority countries from entering the United States sparked outrage but hit a roadblock late on Saturday when a federal judge said stranded travellers could stay in the country.

The emergency court ruling was cheered at Boston's Logan International Airport, one of several major U.S. airports where protesters angry with Trump's order gathered. The American Civil Liberties Union, which sought the temporary stay, said it would help 100 to 200 people with valid visas or refugee status who found themselves detained in transit or at U.S. airports after Trump signed the order late on Friday.

It was a dramatic end to Trump's first week in office, capped by the Republican president's four-month ban on refugees entering the United States and a 90-day hold on travellers from Iraq, Syria, Sudan, Iran, Somalia, Libya, and Yemen.

Trump's order sparked outrage and protests on Saturday.

The new Republican president on Friday put a four-month hold on allowing refugees into the United States and temporarily barred travellers from Syria and six other countries.

Immigration lawyers, activists and Democratic politicians reacted furiously, and many worked to help marooned travellers find a way back home.

Hundreds of protesters gathered at airports in Dallas, Chicago, New York and elsewhere while inside, anxious family members waited and worried for travellers.

At Chicago O'Hare International Airport, brothers Bardia and Ayden Noohi waited for four hours for their father Kasra Noohi — who has an Iranian passport and a U.S. green card — to be allowed through. They knew Trump had pledged tougher rules but did not expect they would affect holders of green cards, which allow foreigners to live and work in the United States.

"I didn't think he'd actually do it," Bardia Noohi, 32, said. "A lot of politicians just talk."

A woman greets her mother after she arrived from Dubai on Emirates Flight 203 at John F. Kennedy International Airport in Queens, N.Y. (Andrew Kelly/Reuters)

Trump, who took office just over a week ago, had promised during his campaign what he called "extreme vetting" to do more to protect Americans from terror attacks.

'It's working out very nicely': Trump

He told reporters in the Oval Office that his order was "not a Muslim ban" and said the measures were long overdue.

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

The ban affects travellers with passports from Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen. Green card holders will not be allowed back in until they are re-screened. The order seeks to prioritize refugees fleeing religious persecution.

At the Los Angeles International Airport, Homa Homaei, a U.S. citizen from Iran, is hugged by a lawyer working to help her Iranian family members affected by the travel ban. (Patrick T. Fallon/Reuters)

In a television interview, Trump said the measure was aimed at helping Christians in Syria.

Confusion abounded at airports as immigration and customs officials struggled to interpret the new rules, with some legal residents who were in the air when the order was issued detained at airports upon arrival.

A chaotic scene played out in the arrivals terminal at John F. Kennedy International Airport in New York, where a group of lawyers had filed a lawsuit on behalf of two Iraqi men who had worked for the U.S. military who were in the air when Trump signed the order.

Thousands of refugees seeking entry were thrown into limbo. Melanie Nezer of the Hebrew Immigrant Aid Society, a Jewish group that works with refugees, said she knew of roughly 2,000 who were booked to come to the United States next week.

Tech industry hampered

The U.S. technology industry, a major employer of foreign workers, hit back on Saturday, with some leaders calling the order immoral and un-American.

Colleges also spoke out on behalf of students from the countries, and warned students in the United States that they should avoid travel lest they not be allowed back in.

Hossein Khoshbakhty wipes tears from his eyes while speaking during an interview about his Iranian brother, a U.S. green card holder affected by the travel ban, at Los Angeles International Airport. (Patrick T. Fallon/Reuters)

Arab travellers in the Middle East and North Africa said the order was humiliating and discriminatory. It drew criticism from U.S. Western allies including France, Germany and Britain.

Iran condemned the order as an "open affront against the Muslim world and the Iranian nation" and vowed to retaliate.

Of the seven countries targeted, Iran sends the most visitors to the United States each year -— around 35,000 in 2015, according to the Department of Homeland Security.

Sudan called the action "very unfortunate" after Washington lifted sanctions on the country just weeks ago for co-operation on combating terrorism.

A Yemeni official expressed dismay at the ban.

Canadians welcome those fleeing persecution, terror and war "regardless of your faith," Prime Minister Justin Trudeau said in a Twitter post.

To those fleeing persecution, terror & war, Canadians will welcome you, regardless of your faith. Diversity is our strength <a href="https://twitter.com/hashtag/WelcomeToCanada?src=hash">#WelcomeToCanada</a> —@JustinTrudeau

During the presidential campaign, Trump promised to clamp down on immigration as a way to prevent attacks. He first proposed a ban on Muslims entering the United States, modifying that later to "extreme vetting" of immigrants from certain countries.

Case-by-case basis

It was unclear how many legal permanent residents would be affected. A senior U.S. administration official said on Saturday that green card holders from the seven affected countries have to be cleared into the United States on a case-by-case basis.

According to State Department guidance, travellers who have dual nationality of one of these countries will not be permitted for 90 days to enter the United States.

Travellers from the Middle East who tried to enter the U.S. were reportedly prevented from boarding at least one flight after U.S. President Donald Trump signed an executive order banning citizens of seven countries from entering the United States. (Louisa Gouliamaki/file photo/AFP/Getty Images)

Legal residents of the United States were plunged into despair at the prospect of being unable to return to the United States or being separated from family members trapped abroad.

In Cairo, five Iraqi passengers and one Yemeni were barred from boarding an EgyptAir flight to New York on Saturday, sources at Cairo airport said. Dutch airline KLM said on Saturday it had refused carriage to the United States to seven passengers from predominantly Muslim countries.