At first, Iran demanded an apology and denounced the "unprofessional" behavior of U.S. warships patrolling in the Persian Gulf.
In Washington, the White House went into crisis-aversion mode and Secretary of State John F. Kerry reached out to his Iranian counterpart. Meanwhile, Republican lawmakers sensed a new opening on a favorite target: last year's nuclear accord between Iran and world powers, which the Obama administration regards as a signature foreign policy accomplishment.
"If our sailors aren't coming home yet, they need to be now," Jeb Bush, former Florida governor and current Republican presidential candidate, vented on Twitter. "Obama's humiliatingly weak Iran policy is exposed again."
In the end, a diplomatic and potential military standoff with Iran was averted Wednesday when Tehran released 10 U.S. sailors who had been taken into custody a day earlier after their two Navy vessels sailed into Iranian territorial waters in the Persian Gulf.
Initially, Iranian officials seemed to cast doubt on U.S. assurances of an early release, saying that the sailors had been "detained," that the "trespassing" would be thoroughly investigated and that a formal apology would be demanded.
Ultimately, however, Tehran publicly accepted the U.S. account that the two boats had strayed inadvertently into Iranian territorial waters off the coast of Farsi Island because of an equipment failure.
"After explanations the U.S. gave and the assurances they made, we determined that [the] violation of Iranian territorial waters was not deliberate, so we guided the boats out of Iranian waters," said Foreign Ministry spokesman Hossein Jaberi Ansari, according to the official Islamic Republic News Agency.
The U.S. confirmed that the sailors left Farsi Island aboard the same riverine command boats that they had been operating when they "lost contact" with the Navy on Tuesday.
The story took a new turn late Wednesday, when Iranian state television aired video of what appeared to be the early moments of the crews' capture. The sailors were seen kneeling in surrender position on a boat deck with their hands on their heads, as an American flag fluttered from the rear of the vessel.
Video aired by Iranian state television appeared to show one of the sailors apologizing for the incident.
The U.S. State Department said no formal apology was proffered to Iran.
It is still unclear if the stricken boat suffered mechanical or navigational failure. The two vessels, known as riverine command boats, were en route from Kuwait to Bahrain when U.S. authorities lost contact with them, the Pentagon said.
"There are no indications that the sailors were harmed during their brief detention," the Navy said in a statement from the commander of the U.S. 5th Fleet in Bahrain. The Navy said it would investigate "the circumstances that led to the sailors' presence in Iran."
Overall, it was an extraordinarily rapid and relatively rancor-free resolution to an incident that easily could have spiraled out of control. Instead, it was all over within 24 hours, the sailors freed unharmed and the boats returned to U.S. custody, with the status quo retained in the Persian Gulf, strategic passageway for much of the world's oil.
Representatives of the two governments seemed to go out of their way to avoid the kind of polemical broadsides that have long characterized U.S.-Iranian relations.
After the sailors' release, comments from Washington and Tehran gave the impression of two old friends just working things out, absent the baggage of decades of animosity.
"Happy to see dialog and respect, not threats and impetuousness, swiftly resolved the sailors episode," Iranian Foreign Minister Mohammad Javad Zarif tweeted. "Let's learn from this latest example."
His U.S. counterpart, Kerry, was equally effusive, thanking Iran for its cooperation.
"That this issue was resolved peacefully and efficiently is a testament to the critical role diplomacy plays in keeping our country safe, secure, and strong," Kerry said, lauding the administration's diplomatic outreach.
A senior State Department official said Kerry and Zarif spoke by phone at least five times over the course of 10 hours to discuss the release of the sailors. The two were already conducting regular, daily conversations involving the implementation of the nuclear arms control deal, the official said.
The official, who spoke to reporters on condition of anonymity in keeping with State Department rules, acknowledged there was concern that if the incident were not resolved peacefully, there could be "spillover" into other areas such as the nuclear deal.
"Had this happened a few years ago before we had this very direct line of communication at a very senior level of our government, it undoubtedly would have been much more complicated to unwind," the official said.
The official insisted that, while the United States did not apologize to Iran for the sailors' trespass, it "did provide context."
"We did explain that this was basically a routine transit mission, that it … had in no way intended to end up anywhere on Farsi Island or in Iranian territorial waters," the official said.
With the sailors' release, both sides appeared to have saved face and deprived domestic hard-line opponents of the nuclear deal of a talking point at a critical moment, when sanctions relief for Iran and new constraints on its nuclear program are about to take effect.
In the end, analysts said, leaders in both Iran and the United States determined that it was in neither nation's interest to escalate the incident in a manner that would inevitably conjure up the darkest chapter in U.S.-Iranian relations — the seizure of the U.S. Embassy in Tehran in 1979 and the subsequent hostage crisis. That episode has left a toxic legacy for a generation.
"The Americans were quick to accept their faults and try not to create tension," noted Mosayeb Naimi, an editor and political observer in Tehran.
The government of Iranian President Hassan Rouhani was clearly not willing to jeopardize the relaxation of sanctions and easing of Iran's international isolation. That the sailors were freed indicates that Iran's supreme leader, Ayatollah Ali Khamenei, approved of the action.
"The [Iranian] government, though it is sensitive to its territorial integrity, is seeking detente now ... on the eve of sanctions being lifted and implementation of the nuclear deal," noted Naimi.
The rapid resolution of such a potentially incendiary incident underscores how things have changed between the United States and Iran, even if the two longtime adversaries have not had formal diplomatic relations since 1980 and are on opposite sides of raging conflicts in Syria and Yemen.
This week's incident could have ended differently.
In 2007, Iran kept 15 British sailors and marines seized off the Iran-Iraq coast in custody for almost two weeks in what became a heated contretemps between the two nations. Then-President Mahmoud Ahmadinejad finally announced that Iran would free the sailors as a "gift to the British people."
In that case, however, London disputed Tehran's assertion that the sailors had violated Iran's territorial waters. War was also raging in Iraq. Another key difference was the presence of the pugnacious Ahmadinejad, whose bellicose style is the antithesis of the low-key, pragmatic approach of Rouhani, whose landslide election in 2013 was a blow to hard-liners in Iran.
"The difference now was the very rational, professional and transparent policy of the Rouhani administration in handling the problem, and the positive effect of direct contact between Zarif and Kerry," said Fereydoun Majlesi, a former Iranian diplomat who is now a columnist.
Still, Rear Adm. Ali Fadavi, who heads naval operations for Iran's Revolutionary Guard, told local television that the episode "could have led to a disaster for the American Navy."
Relief was evident among ordinary Iranians keen for economic progress and unnerved by the prospect of future confrontations with the West.
"I was worried this would escalate into war in the Persian Gulf," said Mehdi Ghadari, 31, a magazine illustrator in Tehran. "The last thing we need is a new round of hostilities."
Special correspondent Mostaghim reported from Tehran and Times staff writer McDonnell from Beirut. Staff writers W.J. Hennigan and Tracy Wilkinson in Washington contributed to this report.
MORE FROM WORLD