US President Donald Trump said Wednesday he has ordered the US military to attack and destroy any Iranian vessel that harasses US Navy ships.

"I have instructed the United States Navy to shoot down and destroy any and all Iranian gunboats if they harass our ships at sea," Trump said on Twitter.

The order came one week after 11 small armed Iranian Revolutionary Guards Corps speedboats swarmed around six US Navy and Coast Guard ships in international waters in the northern Gulf.

US Deputy Secretary of Defense David Norquist called Trump's tweet "an important warning to the Iranians," while not saying whether the US has altered its formal rules of engagement in the Gulf.

"What he was emphasizing is all of our ships retain the right of self-defense," Norquist told reporters in a briefing.

"What the president says sends a great message to Iran," said General John Hyten, vice chair of the Joint Chiefs of Staff.

"We know how to translate that into our rules of engagement ... They are based on the inherent right of self-defense, they are based on hostile intent and hostile act. That's all we need in order to take the right action."

"Nobody should doubt that the commanders have the authority right now to respond to any hostile act or hostile intent," Hyten said.

Trump was referring to an incident that took place on April 15 while US Navy vessels were engaged in exercises as part of their patrols in the region.

This US Navy file photo shows Iranian Islamic Revolutionary Guard Corps Navy (IRGCN) vessels speeding around the guided-missile destroyer USS Paul Hamilton (DDG 60) in the northern Gulf on April 15, 2020
This US Navy file photo shows Iranian Islamic Revolutionary Guard Corps Navy (IRGCN) vessels speeding around the guided-missile destroyer USS Paul Hamilton (DDG 60) in the northern Gulf on April 15, 2020 Navy Office of Information / Handout

No shots were fired, but the Pentagon said the Iranians engaged in "dangerous and provocative actions" that risked collision or worse.

The Iranian Revolutionary Guard Corps boats "repeatedly crossed the bows and sterns of the US vessels at extremely close range and high speeds," coming at one point within 10 yards (nine meters) of the bow of one ship.

The much smaller IRGC Navy vessels ignored warnings from the US ships for about an hour before finally responding to radio communications and then leaving, the US side said.

On Sunday, the Revolutionary Guards accused the US Navy of "unprofessional and provocative behavior" that had interfered with their own exercises, according to Mehr News Agency.

Asked if Trump's order specifically would mean that US ships could fire on Iranian fast boats doing exactly what they did on April 15, Hyten said it is up to the captain of the US vessel.

"It depends on the situation, what the captain sees," he said.

"You can't let a fast boat get in a position where they can threaten your ship.

"If you come across and you're in a safe distance and you're waving, that's one thing," he said.

"If you have a gun and you point it at me, that's another thing ... So if you cross that line, we know what the line is and we will respond."