Hours later, on March 27, Houthi fighters raided the villa and detained Mr. Darden and Mr. Farran on suspicion of being spies. They were among a handful of Americans swept up by the rebels as Yemen unraveled in 2015. One, John Hamen, an Army veteran from Virginia, was tortured and killed.

For months, Mr. Darden endured beatings and interrogations.

After word leaked on Facebook in September 2015 that Mr. Darden was being held captive in Yemen, a spokesman for Transoceanic issued a statement saying Mr. Darden “was in Yemen coordinating the warehousing and delivery of humanitarian aid as part of his job in international logistics.” No mention was made of his secret work with the military.

Later that month, after the men had been in captivity almost six months, prison guards knocked on Mr. Farran’s cell, asking for his shirt and shoe sizes. The brought him out of his cell and forced him to sit in a hallway, he said, where Mr. Darden joined him. They had been separated and saw each other only once during their imprisonment, Mr. Farran said.

“He looked pretty shabby,” Mr. Farran recalled. The men hugged and started crying.

The guards shaved the beards of the two men and brought them clothes. Mr. Farran recalled that guards started videotaping Mr. Darden, but he does not know what Mr. Darden said.

They left the prison and headed to the airport in Sana, where they boarded a Boeing 737 sent by the sultan of Oman, who served as a go-between to gain the Americans’ release. On the flight to Oman, Mr. Darden confided to his friend that he regretted what he had told the Houthis. Mr. Farran tried to comfort him by reminding Mr. Darden that he had been coerced. But, Mr. Farran said, Mr. Darden never told him about a relationship with the American military or why he had rushed back to Yemen.

Yemen has been one of the most active conflict zones for Special Operations forces in the post-Sept. 11 era. It is where the United States is battling hardened Qaeda fighters and where a member of the Navy’s SEAL Team Six died in January in the first commando raid approved by President Trump.

At the time Mr. Darden was captured, about 125 Special Operations advisers had been working closely with Yemeni military and counterterrorism forces. Those advisers and other clandestine operators relied on companies like Transoceanic for much of their logistical support.