A Spanish tourist who was detained in Iran for more than a year has been released, Iran's Foreign Ministry spokesman Nasser Kanaani said on Monday.
Santiago Sanchez Cogedor entered Iran in October 2022 during what he said was a plan to walk from Spain to the Qatar World Cup in November and December 2022.
His release was undertaken "with regard to human mercy and legal proceedings", Mr Kanaani said.
Iran's semi-official SNN news agency said Mr Cogedor had been handed over to officials of the Spanish embassy in Tehran and was due to leave for Madrid shortly afterwards.
Mr Cogedor's family lost contact with him in October 2022. His last message documenting his trip on Instagram appeared on October 1, when he wrote that he was in a village in northern Iraq and headed for the Iranian border.
A voice mail to his parents later broadcast by a television station said he was in Tehran headed for the port of Bandar Abbas, in the Strait of Hormuz, from where he intended to take a boat for Qatar.
Some days later his parents learnt via the Spanish Foreign Ministry of his arrest, his mother Celia Cogedor told AFP in late October.
Mr Cogedor was thought to be the last Spanish citizen detained in Iran.
He was detained as Iran was hit by nationwide protests over the death of a young Iranian woman in custody who had been detained for allegedly breaching laws requiring women to cover their heads.
Mahsa Amini became a protest symbol, with demonstrators forming under the banner 'Women, Life, Freedom.'
Tehran has accused the US of fomenting the protests and had announced in September 2022 the detention of nine foreign citizens from several European states including France, Italy and Poland on the alleged grounds they were linked to the protests.
Western countries accused Iran of detaining foreign citizens to use as bargaining chips for sanctions relief and other goals.
AFP contributed to this report.