By Jeff Mason and Jonathan Allen

WASHINGTON/NEW YORK, Jan 28 (Reuters) - President Donald Trump's order for "extreme vetting" of visitors from seven Muslim-majority countries had an immediate impact on people around the world on Saturday, stranding legal residents of the United States and travelers with visas at airports and infuriating Muslims, Iranians and Western allies alike.

Immigration lawyers and advocates reacted furiously to the order, promising lawsuits after many worked through the night trying to help marooned travelers find a way back home.

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. Protesters gathered in support of the immigrants and lawyers.

In Toronto, Mohammadreza Tayfeh was denied entry to the United States because of his nationality but he found himself comforting the Delta Airlines employee he had called to ask about a refund. "She was so upset," he said.

"To label a whole nation as being terrorists I don't know what to say," said Tayfeh, an Iranian finishing his doctorate in electrical engineering at the University of Saskatchewan in Saskatoon.

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.

The new Republican president on Friday put a four-month hold on allowing refugees into the United States and temporarily barred travelers from Syria and six other Muslim-majority countries. He said the moves would protect Americans from terrorism, in a swift and stern delivery on a campaign promise. urn:newsml:reuters.com:*:nL1N1FH20J

"It's not a Muslim ban," Trump told reporters at the Oval Office. "It's working out very nicely. You see it at the airports, you see it all over."

"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," Trump said.

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. urn:newsml:reuters.com:*:nL1N1FI0GK

The ban affects travelers with passports from Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen. Green card holders who are legal permanent residents of the United States will not be allowed back in until they are re-screened.

Arab travelers in the Middle East and North Africa said the order was humiliating and discriminatory. It drew widespread criticism from U.S. Western allies including France and Germany, Arab-American groups and human rights organizations. urn:newsml:reuters.com:*:nL5N1FI0FM

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. urn:newsml:reuters.com:*:nL5N1FI0I8

Sudan called the action "very unfortunate" after Washington lifted sanctions on the country just weeks ago for cooperation on combating terrorism. urn:newsml:reuters.com:*:nL5N1FI0GN 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. urn:newsml:reuters.com:*:nL1N1FI0E8



LEGAL RESIDENTS STUNNED

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.

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, travelers who have dual nationality of one of these countries will not be permitted for 90 days to enter the United States.

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.

"I never thought something like this would happen in America," said Mohammad Hossein Ziya, 33, who came to the United States in 2011 after being forced to leave Iran for his political activities. urn:newsml:reuters.com:*:nL1N1FI0G1

Ziya, who lives in Virginia, has a green card and had planned to travel to Dubai next week to see his elderly father.

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. urn:newsml:reuters.com:*:nL5N1FI0CI Dutch airline KLM AIRF.PA said on Saturday it had refused carriage to the United States to seven passengers from predominately Muslim countries.

Canada's WestJet Airlines said it turned back a passenger bound for the United States on Saturday in order to comply with the order. A spokeswoman did not say which country the passenger had come from. urn:newsml:reuters.com:*:nL1N1FI0DK



U.S. AGENCIES SCRAMBLE

In Washington, the agencies charged with handling immigration and refugee issues grappled with how to interpret the measure. U.S. officials, speaking on condition of anonymity, said they were not consulted on the executive order and in some cases only learned the details as they were made public.

At the State Department, a senior official said lawyers were working closely with their counterparts at Homeland Security to interpret the executive order, which allows entry to people affected by the order when it is in the "national interest."

However, a federal law enforcement official said, "It's unclear at this point what the threshold of national interest is."

Senior administration officials said it would have been "reckless" to broadcast details of the order in advance of new security measures. The officials told reporters that Homeland Security now has guidance for airlines. urn:newsml:reuters.com:*:nS0N1D900O

After the announcement on Friday evening, enforcement was uneven.

Travelers were handled differently at different points of entry and immigration lawyers were advising clients to change their destination to the more lenient airports, said Houston immigration lawyer Mana Yegani. She said officials denied travelers with dual Canadian and Iranian citizenship from boarding planes in Canada to the United States.

The order seeks to prioritize refugees fleeing religious persecution. In a television interview, Trump said the measure was aimed at helping Christians in Syria.

Lawyers from immigration organizations and the American Civil Liberties Union sued in federal court in Brooklyn on behalf of two Iraqi men, one a former U.S. government worker and the other the husband of a former U.S. security contractor. urn:newsml:reuters.com:*:nL1N1FI09T

The two men had visas to enter the United States but were detained on Friday night at Kennedy airport, hours after Trump's executive order, the lawsuit said. One of the men, former U.S. Army interpreter, Hameed Khalid Darweesh, was later released.

"I don't think anyone is going to take this lying down," said Cleveland immigration lawyer David Leopold. "This is the tip of the spear and more litigation is coming."

(Reporting by Jeff Mason, Roberta Rampton, Doina Chiacu, Lesley Wroughton, Yeganeh Torbati in Washington; Mica Rosenberg, Jonathan Allen and David Ingram in New York; Brendan O'Brien in Milwaukee; Khalid Abdelaziz in Khartoum; Parisa Hafezi in Dubai; Andrea Hopkins in Toronto; Writing by Doina Chiacu; Editing by Grant McCool and Mary Milliken) ((doina.chiacu@thomsonreuters.com; 202-898-8322;))