The directive comes a week after the Navy reported a group of Iranian boats made "dangerous and harassing approaches" to American vessels in the Persian Gulf.
Trump did not cite a specific event in his tweet or provide details. The White House had no immediate comment. The U.S. Navy's Bahrain-based 5th Fleet referred questions about the tweet to the Pentagon, and the Pentagon referred questions to the White House.
Shortly before Trump's tweet, Iran's Revolutionary Guard said Wednesday it had put the Islamic Republic's first military satellite into orbit, dramatically unveiling what experts described as a secret space program.
That launch raised concerns among experts about whether the technology could be used to help Iran develop intercontinental ballistic missiles. Iran currently has short- and intermediate-range missiles.
U.S. Navy ships and Iranian Guard naval vessels occasionally have encounters in the Gulf that the U.S. calls unprofessional, but they rarely escalate or include an exchange of gunfire. Tehran views the heavy presence of American forces there as a security threat.
"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 in his tweet.
Last Wednesday, the U.S. Navy said Revolutionary Guard vessels repeatedly crossed the bows and sterns of several American ships at close range and high speed in the northern Gulf. The American vessels included the USS Paul Hamilton, a Navy destroyer and the USS Lewis B. Puller, a ship that serves as an afloat landing base. The ships were operating with U.S. Army Apache attack helicopters in international waters, the statement said.
The "dangerous and provocative actions increased the risk of miscalculation and collision ... and were not in accordance with the obligation under international law to act with due regard for the safety of other vessels in the area," the Navy said in a statement.
According to the Navy, the Americans issued multiple warnings via bridge-to-bridge radio, fired five short blasts from the ships' horns and long-range acoustic noise maker devices, but received no immediate response, the statement said. After about an hour, the Iranian vessels responded to the bridge-to-bridge radio queries, then maneuvered away.
Iran claimed the U.S. triggered that episode.
American commanders are trained to make nuanced and careful judgment calls about how to respond to incidents at sea. Rather than immediately resort to the use of deadly force, commanders are expected to act based on the specific circumstances, including the threat to their own crews and adherence to the international laws of warfare. Generally, as in the case of last Wednesday's incident, warships will issue warnings by a variety of means, including via bridge-to-bridge radio, before taking more direct action.
Tensions between the nations escalated after the Trump administration withdrew from the international nuclear deal between Tehran and world powers in 2018 and reimposed crippling sanctions on Iran. Last May the U.S. sent thousands more troops, including long-range bombers and an aircraft carrier, to the Middle East in response to what it called a growing threat of Iranian attacks on U.S. interests in the region.
The tensions spiked when U.S. forces killed Iran's most powerful general, QassemSoleimani, in January. Iran responded with a ballistic missile attack on a base in western Iraq where U.S. troops were present. No Americans were killed but more than 100 suffered mild traumatic brain injuries from the blasts. Also, Iran-backed Shiite militias in Iraq continue to threaten American forces there.