According to court papers filed in Downtown Brooklyn, Hameed Khalid Darweesh had worked on behalf of the U.S. government in Iraq for 10 years.
The other detainee, Haider Sameer Abdulkhaleq Alshawi, was coming to the United States to join his wife, who had worked for a U.S. contractor, and young son.
The men arrived on separate flights.
Rep. Jerrold Nadler of New York tweeted that he and Rep. Nydia Velazquez had secured the release of Darweesh.
At an airport news conference, Darweesh was asked about his feelings toward Trump.
"I like him but this is a policy, I don't know,"he said. "He's the president, I'm a person. I have a special immigration visa in my passport because I work with the U.S. government, I support the U.S. government on the other side of the world. But when I came here, they say no and they treat me as I break the rules or do something wrong. That surprise me."
The men were detained after arriving overnight. Their immigration attorneys filed a writ of habeas corpus Saturday morning in the Eastern District of New York seeking to have their clients released.
At the same time, those attorneys filed a motion for class certification, to represent all refugees and immigrants.
Nadler and Velazquez added that 12 travelers have been detained at Kennedy Airport while customs agents clarify how they should be responding to the Trump executive order.
Several hundred protesters gathered at the airport to demand their release.
Meanwhile, Iran's foreign ministry is suggesting the country will limit issuing visas to American tourists in retaliation for Trump's suspension of immigration and visas for nationals from Muslim countries including Iran.
The official IRNA news agency carried a statement by the Iranian foreign ministry that says Iran will resort to "counteraction" to Trump's executive order.
The statement says: "Iran, to defend the dignity of the great Iranian nation, will implement the principle of reciprocity until the removal of the insulting restriction against Iranian nationals."
The statement adds: "It will apply corresponding legal, consular and political actions."
The two countries have had no diplomatic relations since 1979 when militants stormed the U.S. embassy.
[Ads /]
Refugees in the air or on the way to the United States when the order was signed are being stopped and detained at airports, according to immigration advocates.
Seven U.S.-bound migrants - six from Iraq and one from Yemen - were prevented from boarding an EgyptAir flight to Kennedy airport.
[Ads /]
Officials said the action Saturday by the airport was the first since President Trump imposed a three-month ban on refugees from seven Muslim-majority countries: Iraq, Syria, Iran, Sudan, Libya, Somalia and Yemen.
The officials said the seven migrants, escorted by officials from the U.N. refugee agency, were stopped from boarding the plane after authorities at Cairo airport contacted their counterparts in JFK airport.
The airlines flying from this part of the world are updating their travel advisories to reflect the situation.
KLM and Qatar Airways are indicating that green card holders or holders of diplomatic visas (A,G, C-2 or NATO,) from the seven countries are allowed to fly. Tourists and those on study visas are not.
It was a period of limbo for an unknown number of non-American citizens from Iraq, Syria, Iran, Sudan, Libya, Somalia or Yemen now barred from the country where they were studying or had lived, perhaps for years.
[Ads /]
A federal law enforcement official who confirmed the temporary ban said there was an exemption for foreigners whose entry is in the U.S. national interest. It was not immediately clear how that exemption might be applied.
Trump's order exempts diplomats.
Those already in the U.S. with a visa or green card will be allowed to stay, according to the official, who wasn't authorized to publicly discuss the details of how Trump's order was being put in place and spoke only on condition of anonymity.
Customs and Border Protection was notifying airlines about passengers whose visas had been canceled or legal residents scheduled to fly back to the U.S. Airlines were being told to keep them off those flights.
(The Associated Press contributed to this report.)