The US has thanked Iran for the swift release of 10 US sailors held for entering its territorial waters.
Secretary of State John Kerry said the resolution of the matter was "testament to the critical role diplomacy plays in keeping our country safe".
Republican presidential hopefuls had criticised the administration over its handling of the incident.
A deal on Iran's nuclear activities - which they also disparage - is said to be days away from implementation.
The sailors were detained on Tuesday when one of their two vessels broke down while training in the Gulf.
The incursion was "unintentional", a statement from the Iranian Revolutionary Guards quoted by state media said.
Iranian state media said the sailors were released into international waters after they apologised. But Vice-President Joe Biden denied this, saying the boat had had simply a problem and there was "nothing to apologise for".
The US is investigating how the sailors entered Iranian waters.
Thanking Iranian authorities for their "co-operation and quick response", Mr Kerry said: "These are always situations which have an ability if not properly guided to get out of control...
"This kind of issue was able to be peacefully resolved and officially resolved, and that is testament to the critical role diplomacy plays in keeping our country safe, secure, and strong," he added.
Iranian state broadcaster Irib News has published pictures of the sailors apparently being detained.
Later pictures published on the Revolutionary Guards' website showed the group sitting on a Persian rug, with the one female member wearing a headscarf.
Iran-US relations pass a test: Jonathan Marcus, BBC diplomatic correspondent
The tentative and still largely potential softening of relations between Washington and Tehran in the wake of the nuclear deal seems to have passed a delicate initial test.
The Tehran authorities have quickly accepted that the US patrol boats strayed into their waters by accident.
The process to begin lifting the sanctions imposed on Iran due to its nuclear activities is expected to get under way at the end of this week.
There are many conservatives and hardliners in both countries who would dearly love to sabotage the deal. Consequently both governments may well have been eager to get this episode resolved as quickly as possible.
Clearly the economic benefits of lifting the sanctions may have been too great an inducement for the agreement to be derailed now.
Mr Kerry called Foreign Minister Mohammad Javad Zarif shortly after the incident. The pair developed a personal rapport during the nuclear talks.
Those detained - nine men and one woman - were taken to Farsi Island, in the middle of the Gulf, where Iran has a naval base.
Conservatives in both countries have opposed the nuclear deal, under which Iran will limit its nuclear activities in exchange for the lifting of sanctions.
In the US, Republican presidential candidates were among those expressing outrage at the sailors' detention.
"Iran is testing the boundaries of this administration's resolve," said Marco Rubio.
"[Barack] Obama's humiliatingly weak Iran policy is exposed again," Jeb Bush said in a tweet before the sailors were released.
Donald Trump said Iran was "toying" with the US.
Iran's deputy nuclear chief has meanwhile denied a report the Arak heavy-water reactor had been decommissioned, which would be a final step towards implementation of the nuclear deal.
Restraint in Iranian media, by BBC Monitoring
Iranian state media's coverage of the incident has been studiously restrained and measured in tone.
The usual pejorative terms usually reserved for the US and other Western powers - such as "global arrogance" and "enemies" - have been conspicuous by their absence.
State TV and radio reports did highlight that the US incursion had been "illegal" and that Tehran wanted an apology, later reporting that it had got it.
The mood music was far less tense and confrontational than during the capture of British sailors in in 2007, with Iran insisting they strayed into its water - an accusation London denied.
Then, the Iranian media initially accused the UK servicemen of spying, and later mockingly reported that one of them had cried when his music player was confiscated.
Q&A: Iran's nuclear deal
What is it? In July, Iran agreed a landmark nuclear deal with six world powers to limit its sensitive nuclear activities for more than a decade in return for the lifting of crippling sanctions. The US is confident the agreement will prevent Iran from obtaining a nuclear weapon. Iran says it has the right to nuclear energy - and stresses that its nuclear programme is for peaceful purposes only.
When is 'implementation day'? Iran will not see the UN, US and EU sanctions lifted until the global nuclear watchdog, the International Atomic Energy Agency (IAEA), certifies that it has fulfilled its commitments under the deal. Iran reportedly says the IAEA will do so this Friday. US Secretary of State John Kerry says implementation will take place "within coming days".
What does Iran stand to gain? The sanctions have cost Iran more than more than $160bn (£102bn) in oil revenue since 2012 alone. Once they are lifted, the country will be able to resume selling oil on international markets and using the global financial system for trade. Iran has the fourth largest oil reserves in the world and the energy industry is braced for lower prices. Iran will also be able to access more than $100bn in assets frozen overseas.