General Ahmed al-Khafaji, the deputy Iraqi interior minister, said the sailors were released early on Friday through the Shalamcha border police station near the Iraqi-Kuwaiti border and Basra, 550km (340 miles) southeast of Baghdad.
The body of the ninth sailor who was killed in the clash was to be released on Saturday, al-Khafaji added.
Iranian officials were not immediately available for comment.
Al-Khafaji said two Iraqi boats detained by Iran during last Saturday's clash were to be handed over on Saturday, but Muhammad al-Waeli, the governor of Basra, said Iran was going to keep the vessels.
Iraqi officials had said the sailors were detained on 14 January following a clash between Iraqi and Iranian coast guard ships near the Shatt al-Arab waterway, or Arvand River, in the Arab Gulf.
However, the Iranian authorities have denied claims that an Iranian naval vessel fought a skirmish with an Iraqi coast guard ship, instead saying there was a clash between Iranian patrol boats and a merchant ship headed toward Iranian waters.
The Shatt al-Arab waterway runs along the Iran-Iraq border and has long been a source of tension between Iran and Iraq. The 1980-88 Iran-Iraq war broke out after former Iraqi leader Saddam Hussein claimed the entire waterway.