Jahani had been appointed as consul to the city of Karbala, but was captured en route on 4 August.
Abbas al-Attar the Iranian ambassador in Baghdad told Aljazeera: "Mr Fereydun Jahani has been freed and is safe in the Iranian embassy in Baghdad."
"His release was not conditional," Mr al-Attar said.
Relations between Baghdad and Tehran soured after Iraq's Defence Minister Hazim al-Shaalan accused Iran of sending spies and arms across the border to foment unrest among the Shia majority.
"Through talks with my captors, they were convinced it was not Iran's intention to interfere in their state matters ... therefore they released me," Jahani was quoted as saying by Iran's state television who spoke to him in Baghdad on Monday.
It was not immediately clear who conducted these talks.
Initial reports said he was taken by a group calling itself the Islamic Army in Iraq, but Iran's state television said the captors were from an unknown faction.
"Through talks with my captors, they were convinced it was not Iran's intention to interfere in their state matters"
The Islamic Army in Iraq was also thought to have seized French journalists Georges Malbrunot and Christian Chesnot on 21 August. The same group killed Italian reporter Enzo Baldoni on 26 August.
Iraqi groups have seized and executed a string of foreign and local captives in recent months. Among others, they are holding two Frenchmen, two Italian women and a British man.
Iranian officials were not immediately available for comment.