Gibraltar has rejected a request by the US to again seize an Iranian tanker that it has been holding since July on suspicion of transporting oil to Syria.
The US made the last-minute request on Friday, a day after Gibraltar lifted its detention order against Grace 1.
Gibraltar said it could not comply with Washington's request to issue a new detention order because US sanctions against Iran did not apply in the EU.
The tanker was due to leave Gibraltar later on Sunday (local time), Iran's UK envoy says.
Tehran said it was ready to dispatch its navy to escort the ship, which has had its named changed from Grace 1 to Adrian Darya 1.
The ship with its crew of 29 - from India, Russia, Latvia, and the Philippines - was seized with the help of British marines on 4 July, after the government of Gibraltar - a British territory - suggested it was heading for Syria in breach of EU sanctions.
The move sparked a diplomatic crisis between the UK and Iran, which has escalated over recent weeks and saw Iran seize a British-flagged and Swedish-owned oil tanker, Stena Impero, in the Gulf.
The Gibraltar authorities freed the vessel on Thursday after receiving assurances from Iran that it would not discharge its cargo in Syria.
The US justice department then filed a request to detain the ship on the grounds that it had links to Iran's Islamic Revolutionary Guard Corps, which it has designated a terrorist group.
Gibraltar, in a statement on Sunday, said it could not comply with the request because the Revolutionary Guard is not viewed as a terrorist organisation by the EU, which the British territory is currently part of.
It also said that American sanctions preventing oil exports from Iran cannot be enforced by the EU, reflecting what it said were "the very different positions and legal regimes in the US and the EU".
There has been no response yet from Washington.
Iran's ambassador to Britain, Hamid Baeidinejad, tweeted on Sunday that two specialist engineering teams were on their way to Gibraltar and said: "The ship is expected to depart tonight."
The Stena Impero, which was seized by the Revolutionary Guard on 19 July, remains in Iranian hands.
The UK has since announced it would join a US-led taskforce to protect merchant ships travelling through the key shipping route in the Strait of Hormuz.
Tensions between Iran and the West can be traced to the resurgence of another crisis - that over Iran's nuclear programme.
Last year, Washington withdrew from a 2015 deal to limit Iran's nuclear activities amid suspicion that Tehran was still trying to develop nuclear weapons, something Iran has always denied.
Since then, US-Iran tensions have grown after Washington imposed - and latterly tightened - its sanctions against the country.
The UK and other European countries have said they remain committed to the deal.