If an online travel agency had not temporarily blocked a credit card payment, forcing him to rebook a later flight, Hameed Khalid Darweesh probably would have landed at Kennedy International Airport in New York before President Trump signed his executive order restricting refugees and immigrants from predominantly Muslim countries.

Instead, the Iraqi immigrant, who worked with the United States military and government for a decade at great personal risk, watched as his wife and three children disappeared into the main part of the arrivals terminal early on Friday evening. Instead of being allowed to accompany them, Mr. Darweesh found himself detained overnight — at times handcuffed — and unsure if he would be returned to Iraq, the country he had fled in fear for his life.

“We have a moral obligation to protect and repay these people who risked their lives for U.S. troops,” said Brandon Friedman, who, as an infantry lieutenant with the 101st Airborne Division, worked with Mr. Darweesh in Iraq. Mr. Friedman later served in the Obama administration at both the Department of Veterans Affairs and the Department of Housing and Urban Development.

“There are not many Americans who have done as much for this country as he has,” Mr. Friedman added. “He’s put himself on the line. He’s put his family on the line to help U.S. soldiers in combat, and it is astonishing to me that this country would suddenly not allow people like that in.”