Shane Bauer and Josh Fattal left their Tehran jail after Omani and Swiss officials travelled there to mediate their release. Reports said bail had been set at $500,000 each (£324,000), or 5 billion riyals.
Shane Bauer and Josh Fattal, both 29, were convicted last month of entering Iran illegally as spies for the United States.
They were arrested in July 2009, along with their friend, Sarah Shourd, 33, after crossing an unmarked border between Iran and Iraq. Shourd was released last September on health grounds, on bail of $500,000.
Ms Shourd and Mr Bauer became engaged while in prison.
Their release comes a week after President Ahmadinejad told US media outlets that the pair had been granted a “unilateral pardon”.
But Iran’s judiciary later cast doubt on the release.
Analysts say the move is an attempt to smooth tensions with the international community over its nuclear programme.
Watch Sarah Shourd’s interview on Channel 4 News about the “dire” living conditions in their 10 x 4 foot cell.