Gibraltar has freed an Iranian oil tanker detained last month on suspicion of sanctions-busting, despite a last-minute plea by the United States authorities.
The British overseas territory received written assurances from Iran that the ship would not discharge its cargo in Syria.
Grace 1, which was suspected of smuggling Iranian oil to Syria, was stopped by Royal Marines on July 4, triggering a standoff with Tehran.
Gibraltar's Supreme Court was set to release the Grace 1 when the US Justice department applied for the vessel to be seized.
But Chief Justice, Anthony Dudley, said no US application was currently before the court.
An independent legal body would make a determination on the American request, Gibraltar's Chief Minister Fabian Picardo said in a statement.
The tanker remained off Gibraltar early on Thursday evening but, according to witnesses speaking to Reuters news agency, its prow had moved around by at least 180 degrees.
It was unclear whether this was because of strong sea currents or because it was preparing to leave.
The UK Foreign and Commonwealth Office said Iran must abide by the assurances it had given that the tanker would not proceed to Syria, which is under EU sanctions.
The FCO described Syria as a "regime that has deployed chemical weapons against its own people".
The captain and three officers from Grace 1, had their police bail lifted and were formally released without any charges, a Gibraltar government spokesman said.
Iranian Foreign Minister Javad Zarif condemned the US attempt to stop the tanker's release, accusing the Trump administration of attempted "piracy".
Iranian authorities believe Britain detained the ship at the behest of the Trump administration.
Iran described Britain's actions as "piracy" and hit back a couple of weeks later by seizing a British tanker, the Stena Impero, on July 19 in the strategic Strait of Hormuz -- the conduit for much of the world's crude -- for breaking "international maritime rules".
Despite official denials, there has been speculation of a swap if the Grace 1 is freed.
Relations between the US and Iran have deteriorated sharply since US President Donald Trump took office in 2017, with the two countries coming close to armed conflict in June.
SEIZING OF IRANIAN TANKER
It was stopped after the government of Gibraltar suggested it was heading for Syria.
About 30 marines were flown from the UK to Gibraltar to help police detain the tanker and its cargo, at the request of the Gibraltarian government.
The initial seizure of the tanker sparked a diplomatic crisis between the UK and Iran which escalated when the Stena Impero was seized on July 19.
Last week, the UK announced it would join a US-led taskforce to protect merchant ships travelling through the key shipping route in the Strait of Hormuz.
Almost a fifth of the world's oil passes through the narrow strait, which lies off the south coast of Iran.
Why american request was not considered
Confirming that the tanker had been "released from detention", Gibraltar's Chief Minister Fabian Picardo explained that the US justice department had requested that a "new legal procedure for the detention of the vessel should be commenced".
"That is a matter for our independent Mutual Legal Assistance authorities who will make an objective, legal determination of that request for separate proceedings," he said.
Situation of Uk tanker
The Stena Impero, which is British-flagged but Swedish-owned, is anchored in the Iranian port of Bandar Abbas, 27 days after being detained.
Tehran said Stena Impero had been "violating international maritime rules" but the UK called its detention an example of "state piracy".
Global seafarers' charity Stella Maris said it hoped the release of Grace 1 might in turn lead to the release of the Stena Impero's crew.
Iran released photos of the crew aboard the tanker last month, showing cooks preparing meals and crew members being briefed by an Iranian official.
Most of the crew of 23 are Indians while the others are of Russian, Latvian or Philippine nationality.
Most of the 28 members of the Grace 1's crew are also believed to be Indians.
Why US-Iran relations are strained
Washington suspects Iran of continuing efforts to develop nuclear weapons, something Tehran has always denied, and also accuses it of seeking to destabilise the Middle East.
Last year, the US withdrew from a 2015 deal to limit Iran's nuclear activities and re-imposed sanctions against the country.
The UK and other European countries have said they remain committed to the deal.
Iran responded by suspending some of its commitments under the nuclear deal.
The situation threatened to spiral out of control with ships attacked, drones downed and oil tankers seized.
At the height of the crisis, Trump called off air strikes against Iran at the last minute in June after its forces shot down a US drone.
Washington blames Iran for the series of attacks on tankers in waters off Gulf Arab states, an accusation Tehran denies.
President Hassan Rouhani said on Tuesday that Iran favours talks with the US if it lifts sanctions against the Islamic republic.
"Peace for peace and oil for oil," he said. "You cannot say that you won't allow our oil to be exported.
"It cannot be that the Strait of Hormuz is free for you and the Strait of Gibraltar is not free for us."
-Additional reporting by AFP