DUBAI (Reuters) - Iran's navy warned a U.S. warship on Wednesday to leave waters near the Strait of Hormuz where the Iranians were testing submarines, destroyers and missile launchers, news agencies reported.

The commander of Iran's fleet, Rear-Admiral Habibollah Sayyari, told Tasnim news agency the U.S. ship was trying to collect information in the Sea of Oman - an area close to the Strait, a vital oil and gas shipping route - and said it left quickly after the alert.

There was no immediate reaction from Washington which this month joined other world powers in lifting sanctions on the Islamic Republic after Iran agreed to curtail its nuclear program.

In the days before that deal, Iran briefly detained 10 U.S. sailors after their boats entered its waters because of what they said was a navigational error.

"It was predictable that the U.S. warship would approach the area to collect information on (our) military operations. So we warned them twice in the morning ... to keep their distance from the exercise area and keep clear of our missile range for their own safety," Sayyari was quoted as saying by Tasnim.

He said Iran had acted in line with the international convention that a country should clear out all other military and trade ships from an area before starting any exercise.

"The maneuver aims to show Iranian forces' strength both in ensuring security on the seas and in defending the country's sea borders in Hormuz Strait, Sea of Oman and north of the Indian Ocean," Sayyari was quoted as saying by state news agency IRNA.

Tasnim news agency reported on Wednesday that Iran had given warnings to other Western ships on Tuesday, and they had all left the area.

(Reporting by Bozorgmehr Sharafedin; Editing by Andrew Roche)