A container ship seized in the Strait of Hormuz by Iran last week has been released, its operator has confirmed.
Rickmers Shipmanagement said the 24 crew members of the Maersk Tigris were "in a good condition".
The Marshall Islands-flagged vessel was intercepted by Iranian patrol boats on 28 April and taken to Bandar Abbas.
Iran said the ship was detained because of a legal dispute between the Danish company chartering it, Maersk, and a private Iranian firm.
Maersk says the dispute dates backs to 2005, when it delivered 10 containers to Dubai for Pars Oil Products. The containers were not collected and the cargo was disposed of after 90 days by the UAE authorities, it asserts.
The Iranian company subsequently accused Maersk of default and claimed $4m (£2.6m) as the value of the cargo. Maersk said it challenged the suit successfully and in 2007 the case was dismissed.
However, an appeals court ordered it to pay $163,000 (£107,400) in February.
Iran's Ports and Shipping Organisation said permission for the release of the ship was given on Thursday after Maersk "ensured the provision of a letter of guarantee for the enforcement of the judicial decision".
A Maersk statement said the release followed "a constructive dialogue with the Iranian authorities, including the Ports and Maritime Organization, and the provision of a letter of undertaking in relation to the underlying cargo case".
"We will continue our dialogue with the aim to fully resolve the cargo case."
Danish Foreign Minister Martin Lidegaard said the government was involved in the negotiations.
"For Denmark as a seafaring nation, it is obviously a priority that international obligations are complied with and that ships can sail in the Persian Gulf," he added.
The ship was expected to arrive at Jebel Ali, in the United Arab Emirates, late on Thursday or early Friday, where it will be met by representatives of Rickmers.
The seizure of the Maersk Tigris in one of the world's major shipping lanes threatened to turn into an international incident.
Shots were fired across the bow of the vessel by the Iranian patrol boats before it agreed to change course for Bandar Abbas.
The US called the Iranian action "unacceptable" and sent the destroyer USS Farragut to the area to monitor the situation.
Maersk said its ship was in an international shipping lane when it was detained, but Tehran insisted it had been in Iranian waters.