NEW YORK (Reuters) - A federal judge blocked the deportation on Saturday of dozens of travelers and refugees from seven Muslim-majority nations, stranded at U.S. airports under an order from President Donald Trump, after a lawsuit filed on behalf of two Iraqis with ties to U.S. security forces.

In the lawsuit filed in federal court in Brooklyn, New York, the two men challenged Trump’s directive on constitutional grounds. The suit said their connections to U.S. forces made them targets in their home country and that the pair had valid visas to enter the United States.

The lawsuit highlights some of the legal obstacles facing Trump’s new administration as it tries to carry out the directive, which the president signed late on Friday to impose a four-month ban on refugees entering the United States and a 90-day hold on travelers from Syria, Iran and five other Muslim-majority countries.

In an emergency ruling on Saturday, U.S. District Judge Ann Donnelly ordered U.S. authorities to refrain from deporting previously approved refugees as well as “approved holders of valid immigrant and non-immigrant visas and other individuals ... legally authorized to enter the United States” from the countries targeted in Trump’s order.

The American Civil Liberties Union, which sought the temporary stay, said it would help about 100 to 200 people who found themselves detained in transit or at U.S. airports after Trump signed the order.

“I am directing the government to stop removal if there is someone right now in danger of being removed,” Donnelly said in the court hearing. “No one is to be removed in this class.”

U.S. Department of Justice attorney Susan Riley during the hearing said, “This has unfolded with such speed that we haven’t had an opportunity to address all the legal issues.”

Many of the people in a huge crowd that had gathered outside the Brooklyn courthouse broke out into cheers after word of the judge’s ruling filtered out.

The U.S. Department of Homeland Security in a statement hours later said only a small fraction of airline passengers arriving in the United States on Saturday were “inconvenienced while enhanced security measures were implemented.”

Slideshow ( 3 images )

“These individuals went through enhanced security screenings and are being processed for entry to the United States, consistent with our immigration laws and judicial orders,” the statement said.

The department said Trump’s executive order remained in place and that its officers would enforce it.

Separately, a group of state attorneys general were discussing whether to file their own court challenge against Trump’s order, officials in three states told Reuters.

“TARGETED BY TERRORISTS”

The plight of one of the men who brought the lawsuit, a former U.S. Army interpreter who was detained at John F. Kennedy International Airport, is especially compelling, said David Leopold, a former president of the American Immigration Lawyers Association, who is not involved in the suit.

“Here is a guy who was a translator who worked for the U.S. military for years, who himself was targeted by terrorists,” he said. “It is clear that if he is sent back, he is facing a direct threat to his life.”

That man, Hameed Khalid Darweesh, was released later on Saturday and told a crowd of reporters at JFK Airport that he did not have ill feelings about his detention.

“America is the greatest nation, the greatest people in the world,” he said.

Slideshow ( 3 images )

Darweesh, 53, worked for the U.S. Army and for a U.S. contractor in Iraq from 2003 to 2013 as an interpreter and engineer, the lawsuit said.

The second plaintiff, Haider Sameer Abdulkhaleq Alshawi, 33, was also detained at JFK Airport but has since been released. He is the husband of an Iraqi woman who worked for a U.S. contractor in Iraq. She already lives in Houston, the suit said.

Trump, a Republican, has said his order would help protect Americans from terrorist attacks.

The lawsuit on behalf of the Iraqis challenges Trump’s order on several grounds. It says the order violates the U.S. Constitution’s guarantee of due process by taking away their ability to apply for asylum, and violates the guarantee of equal protection by discriminating against them on the basis of their country of origin without sufficient justification.

It also says the order violates procedural requirements of federal rulemaking.

The next hearing in the case was set for Feb. 10.

Supporters of the order say the president has wide authority to limit the entry of foreign nationals from specific countries when it is in the national interest.

“Even if they do and they win, my answer is so what?” said Mark Krikorian, the director of the conservative Center for Immigration Studies.

“We are talking a few dozen people – that is just a last-ditch effort to get the last few people in. It doesn’t really change the policy,” he said.

Trump’s order does not mention specific religions but Trump said in an interview with the Christian Broadcasting Network on Friday he was acting to help Christians in Syria who were “horribly treated.”

Comments like that could come back to haunt the president in litigation over his order, said Hiroshi Motomura, an immigration expert at UCLA School of Law.

“There were comments during the campaign that focused very much on religion as the target,” Motomura said. “If the record showed that the origins of a particular measure were based on targeting a particular group, that could be challenged in court.”