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.
Siding with Tehran, it said exports of "humanitarian" goods, such as food and medicines, should be allowed.
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 both nations have in the past ignored the court's rulings.
Announcing the decision 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."
The Iranian foreign ministry said the decision "vindicates the Islamic Republic of Iran and confirms the illegitimacy and oppressiveness" of US sanctions.
However, the US ambassador in the Netherlands, Pete Hoekstra, pointed out in a tweet that the "court declined… to grant the sweeping measures requested by Iran" – after dismissing the entire case as "meritless".
Iran's economy has slumped since US President Donald Trump ordered that sanctions be reinstated in May. Its currency, the rial, has dropped sharply.
Analysis by Anna Holligan, BBC News, The Hague
The order calls for a partial easing of punitive measures. It covers medicines, medical supplies and equipment, food, agricultural products and aviation safety equipment.
This is essentially the first time international judges have ruled on what's been described as a case of "economic warfare".
It is a provisional measure issued in response to Iran's urgent request ahead of the second round of sanctions scheduled to be reinstated next month.
The decision could encourage European companies, which ceased trading with Iran for fear of falling foul of President Trump, to reconsider their position, specifically those dealing in the humanitarian items outlined by the judges.
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 US state department has also said humanitarian-related exports of food, medicine, and medical equipment are allowed under current sanctions.
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.
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.