The British-flagged Stena Impero tanker sailed out of Iranian waters on Friday, the owner said, after it was detained in July during a row with Britain that has stoked tensions in the Gulf.
The Stena Impero left Iran's Bandar Abbas port on Friday morning bound for Dubai, where the crew would be repatriated, Sweden's Stena Bulk said, after being detained for 10 weeks.
The ship was seized by Iran's Revolutionary Guards in the Strait of Hormuz, a major oil shipping route, for alleged marine violations two weeks after Britain detained an Iranian tanker off the territory of Gibraltar. The Iranian ship was released in August.
"It reached international waters," Stena Bulk CEO Erik Hanell told Reuters in a text message after the Stena Impero began sailing, adding that the ship's master "reported that all crew members are safe and in high spirits following release."
He said the crew would receive medical checks and be de-briefing in Dubai in the United Arab Emirates, on the opposite side of the Gulf, before travelling home to their families. Seven of the 23 crew were freed earlier this month.
The seizure of the ship ratcheted up tension after attacks in May and June on other merchant vessels in Gulf waters, which the United States blamed on Iran, a charge Tehran denied.
The Ports and Maritime Organization of Iran in the country's southern Hormozgan Province said the ship started to move out from Bandar Abbas at 9 a.m. Iran time (0530 GMT).
But it said the judicial file on the vessel remained open and the process of looking into "violations" by the ship was ongoing.
Iran's Foreign Ministry had said on Wednesday that the detention order had been lifted but the investigation continued.
Stena Bulk said on Wednesday it was not in negotiations with Iran and said it was not aware of any formal charges against the crew or the company.
Relations between the United States and Iran have become more strained since Washington withdrew last year from a global pact to rein in Tehran's nuclear programme and imposed sanctions on the country aimed at shutting down Iranian oil exports.