The Arleigh Burke-class guided-missile destroyer USS Mahan is shown moored in Piraeus, Greece, on Dec. 11, 2016. (Photo by Petty Officer 1st Class Tim Comerford/ Navy)

A Navy destroyer opened fire Sunday in the Strait of Hormuz after four Iranian Revolutionary Guards Corps patrol boats acted in a way that a U.S. defense official described as “harassing.”

The USS Mahan, a guided-missile destroyer, fired three warning shots with a .50-caliber machine gun at four Iranian boats after at least one of them traveled within 900 yards of the Mahan with a sailor manning its main gun. The Mahan was traveling north through the strait toward the Persian Gulf with two other Navy vessels, the amphibious craft USS Makin Island and the oiler USNS Walter S. Diehl, said Navy Capt. Jeff Davis, a Pentagon spokesman.

“This was an unsafe and unprofessional interaction,” Davis said, citing the speed with which the Iranians approached and the manning of the weapons on board. “They only stopped their approach following the warning shots being fired.”

Davis said the incident marks a return to a series of provocative encounters between U.S. and Iranian vessels that had started to wane over the latter half of 2016. The Navy counted 23 interactions in 2015 and 35 in 2016 that included actions by the Iranians that were considered “unsafe and unprofessional,” but the last significant one occurred in August. In that incident, the coastal patrol ship USS Squall fired three warning shots after three Iranian boats approached the Squall and another similar U.S. ship, the USS Tempest, at a high rate of speed.

The incidents last year involving Iranian and U.S. vessels also included one in which the Iranians took 10 U.S. Navy personnel at gunpoint and held them blindfolded overnight, angering U.S. officials and embarrassing the Navy. The service later determined that the unit involved was “poorly led and unprepared,” and removed at least three officers from their jobs.

In the incident Sunday, the Iranian boats broke away after the warning shots were fired, and established radio contact with the Mahan afterward to ask for the destroyer’s course and speed, U.S. officials said.

Recent incidents between the U.S. Navy and Iran are the latest signs of friction near Iran's coast between the two countries. (Missy Ryan,Jason Aldag/The Washington Post)

The move came one day before Iran’s parliament on Monday approved expanded military spending, including funds for its long-range missile program, Iranian media reported.

Iran insists its ballistic missile tests do not violate a 2015 accord with world powers aimed at curbing Tehran’s nuclear program. But the nuclear deal specifies that Iran halt development of missiles capable of carrying nuclear payloads. Iran, in turn, claims its missile program is not designed for such warheads.

Trump has pledged to oppose any expansion of Iran’s missile capabilities, which Iran asserts can already reach Israel and other points in the region.

Iran’s Tasnim news agency said the enlarged military spending also includes programs such as armed drones and cyber warfare capabilities.

Missy Ryan and Brian Murphy contributed to this report.