A court in Gibraltar has released the Iranian oil tanker Grace 1, according to the chief minister's statement.
The vessel was seized in July because it was suspected to be in breach of EU sanctions, Euronews reports.
Gibraltar Chief Minister Fabian Picardo decided to lift the detention order after Tehran confirmed in writing they would not discharge the oil in Syria.
"The Grace 1 is therefore now released from detention under the Sanctions Act by operation of law as confirmed this afternoon by the Chief Justice of the Supreme Court," said the statement.
However, it remains unknown when the tanker will leave Gibraltar.
Earlier on Thursday, the U.S. government applied to block the release of the tanker.
A senior official with the Chief Minister of Gibraltar's office told Euronews "The United States has applied to seize the vessel based on a number of allegations put to the Government of Gibraltar.
"Those allegations will be considered back in court today at 4 pm local time (CEST)."
The official did not reveal the nature of the allegations made.
Picardo said the U.S. Department of Justice request for a new legal procedure to further detain the ship would be looked at by "the independent Mutual Legal Assistance authorities" who would "make an objective, legal determination of that request for separate proceedings".
Iran's ambassador to the UK, Hamid Baeidinejad, said the United States was "desperately" trying to block the release but faced a "miserable defeat".
The Grace 1 and its crew consisting of cizitens of Pakistan, India, and Ukraine, were seized following a British Royal Navy operation in July after the tanker was suspected of violating EU sanctions on sending oil which could be used by the Assad government in Syria.
Gibraltar is an overseas territory of the United Kingdom on the southern tip of Spain.
The UK government has said it is up to Gibraltar to decide what to do and the court said it was seeking to "de-escalate" the situation with Iran.
It comes amid mounting tensions between the West and Iran after the U.S. pulled out of the 2015 nuclear treaty last year.