The International Court of Justice has told the US it was wrong to attack Iranian oil platforms in the 1980s.
But the court did not grant either Washington or Tehran the compensation both sides had demanded.
Tehran filed a claim against the US for damages after it attacked three Iranian oil platforms in 1987 and 1988.
But the US also claimed compensation for what it said was damage caused by Iran to commercial ships sailing under the American flag.
"The actions of the United States of America... cannot be justified as measures necessary to protect the essential security interests of the United States of America," a statement from the court said.
"The United States was only entitled to have recourse to force... if it was acting in self-defence," it said.
Iran filed its complaint to the court in 1992, saying that the US attack on its oil installations violated a 1955 treaty of political and economic friendship between the two countries.
US warships destroyed the first platform in October 1987 after an Iranian missile injured 18 crew on a US oil tanker.
Washington - which supported Iraq in the war - ordered two more off-shore installations to be destroyed in April 1988 after 10 sailors on a US frigate were injured in a mine explosion.
The US said the oil platforms were being used to launch attacks on shipping in the Gulf, but Iran denied the charge.