The International Court of Justice (ICJ) has ordered the US to ease sanctions it re-imposed on Iran after pulling out a nuclear deal last year.
The ICJ sided with Iran, which said the sanctions were causing suffering and were in violation of a 1955 treaty.
The US argued the court had no jurisdiction in the case as it concerned its national security.
The rulings of the ICJ - which is based in The Hague - are binding but the court has no power to enforce them.
It is the main judicial organ of the UN and settles legal disputes between member states. But the BBC's Hague correspondent, Anna Holligan, says both nations have in the past ignored the court's rulings.
Announcing the ruling on Wednesday, the court's president, Judge Abdulqawi Yusuf, said: "The court considers that the United States must remove, by means of its choosing, any impediment (...) to the free exportation to the territory of Iran of goods required for humanitarian needs."
Iran's economy has slumped since US President Donald Trump ordered that sanctions be reinstated in May. Its currency, the rial, has dropped sharply.
What were the arguments in court?
Iran said the sanctions violated the 1955 Treaty of Amity, Economic Relations, and Consular Rights between Iran and the US, which grants the ICJ jurisdiction over disputes.
It also said the reasons cited by President Trump for re-imposing the sanctions were unfounded because the International Atomic Energy Agency
(IAEA) had repeatedly confirmed that Iran was complying with the terms of the 2015 nuclear accord signed by Tehran and six world powers.
US lawyers argued that the ICJ should not have jurisdiction and that Iran's assertions fall outside the bounds of the treaty.
The ICJ has ruled previously that the 1955 treaty is valid even though it was signed before the 1979 Revolution in Iran, which saw the US-backed shah overthrown and heralded four decades of hostility between the two countries.
Why did the US abandon the nuclear deal?
The 2015 accord saw the Islamic Republic limit its controversial nuclear activities in return for relief from international sanctions.
But Mr Trump said the deal had "failed to achieve the fundamental objective of blocking all paths to an Iranian nuclear bomb" and did not deal with Tehran's "malign activities, including its ballistic missile programme and its support for terrorism".
In an attempt to compel Iran to agree to a new accord, the president reinstated sanctions that targeted the Iranian government's purchase of US dollars, Iran's trade in gold and other precious metals, and its automotive sector.
In November, a second batch of potentially more damaging sanctions will be re-imposed on Iran's oil and shipping sectors as well as its central bank.
The other parties to the deal - the UK, France, Germany, China and Russia - have pledged to abide by their commitments under the existing deal. But many major firms have already pulled out of Iran.