Iran is setting free the 15 British sailors and marines who have been held captive since its navy arrested them in the Persian Gulf March 23.
"I declare that the people of Iran and the government of Iran, in full power to place on trial the military people, to give amnesty and pardon to these 15 people, and I announce their freedom and their return to the people of Britain," Iranian President Mahmoud Ahmadinejad told a news conference.
Ahmadinejad described his decision as a goodwill gesture, and he said the British personnel would be taken to the airport and let go.
The members of the Royal Navy were picked up last month while they were conducting inspections of vessels near the line separating Iran's waters from Iraq's. Iran claimed they were trespassing, while London maintained that they were in Iraqi territory.
Iran had initially threatened to put the Britons on trial but in recent days had backed off the threat.
Officials in Britain, who were pressing for talks aimed at getting the group back, had been incensed at the fact that Iran had put the crewmembers on television early in the dispute and extracted alleged confessions from them about how they were trespassing.