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 surprised 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 JFK Airport while customs agents clarify how they should be responding to the Trump executive order.
Protesters gathered at the airport Saturday to denounce the order.
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.
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.
Officials said the action by the airport was the first since 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 International Airport contacted their counterparts in JFK Airport.
The airlines flying from this part of the world were 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.
(The Associated Press contributed to this report.)