Iran's Joint Military Command warned on Thursday that all oil tankers passing through the Strait of Hormuz must use approved routes or face a "strong response," the AP reported.
The warning has again heightened tensions over the waterway, which is crucial to international energy supplies.
The strait, a narrow mouth of the Persian Gulf, has emerged as one of the main issues in talks aimed at a final end to the war with Iran. The statement from the Khattam al-Anbiya military command, carried by Iranian state television, came after U.S. and Iranian diplomats met with mediators in Qatar on Wednesday.
It was not clear what prompted the threat from Iran. However, the U.S. Central Command issued a statement about a meeting with representatives of Middle Eastern countries in Bahrain, saying that "leaders stressed their shared commitment to the free flow of trade throughout" strait.
That may be the phrase that has angered Iran, which is preparing for the funeral starting this weekend of the late Supreme Leader Ayatollah Ali Khamenei, who was killed in the early stages of the war in February.
"Any non-compliance, deviation from the designated route or disregard for the navigation protocols of the Islamic Republic of Iran in the Strait of Hormuz will be met with an immediate and strong response from the armed forces, endangering the security of the violators," the Iranian statement said.
It also said that interference by US forces in the strait "will be met with a swift and decisive response."
Iran and the United States have agreed as part of an interim agreement to allow ships to pass through without paying fees for 60 days. But Tehran has insisted it must control the ships' routes and later charge them to pass through, reversing decades of practice in the waterway.
The United States and many Gulf Arab states will not agree to Iran charging tolls for passage through the strait. Efforts by Oman and a UN agency to open a new route near the Omani coast sparked attacks in the Middle East last weekend, underscoring tensions.
Despite the attacks, shipping traffic in the strait has continued to recover. At least 258 ships passed through the waterway last week, according to maritime data and analytics firm Lloyd's List Intelligence, and two merchant ships were also attacked by Iran during that period. That's up from 138 ships the previous week.