The pirates panicked. Their unity broke down. Each man hoped, variously, to surrender, find cover or hide. Discarding their weapons, nine of them crammed into a small hold beneath the wheelhouse. Six more huddled near the open bow.

Soon, armed American sailors climbed aboard. They spotted the six Somalis on the bow, who did not resist. As more of the boarding team swarmed over the side, the Iranian hostages pointed to where the remaining pirates were hiding. The sailors pulled those men out, one by one, into the light and forced them face down onto the deck.

Al Mulahi was secured. The Iranian hostages had been saved without a shot being fired.

In interviews by two journalists from The New York Times who spent Thursday night on the rescued vessel, the former hostages, the captured pirates and the American sailors guarding them told of a drama on the open ocean: Naval vessels, helicopters and inflatable boats first thwarted a pirate attack and then converged on the pirates’ roving base, freeing 13 hostages who had expected to die.

The operation was a geopolitical thriller, as the aircraft carrier John C. Stennis, which had been warned not to return to the region by senior Iranian defense officials on Tuesday, answered on Thursday by swiftly organizing the rescue of Iranian hostages not far from Iran’s coast.

But the rescue was also the dramatic finale to a slow-moving ordeal for the hostages. To survive more than six weeks after their 82-foot gillnetter was captured at gunpoint and converted to a platform for attacks against international shipping, the fishermen relied on calm nerves, prayer, camaraderie and, in the end, duplicity.