Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

By Courtney Kube and The Associated Press

A senior Department of Defense official said Thursday that a U.S. Navy ship, the USS Squall, fired several warning shots near an Iranian "fast boat" on Wednesday

The Squall, a patrol craft, and the USS Tempest, were operating in close formation with a Kuwaiti Navy ship in the North Arabian Gulf when the Iranian boat came dangerously close. At one point the Iranian craft passed between the two U.S. ships, coming within a couple hundred yards of the U.S. ships.

The patrol craft USS Squall (PC 7) transits in the Gulf acting as a small boat threat towards the guided-missile destroyer USS Mitscher (DDG 57) during a simulated strait transit while participating in Spartan Kopis 15-01 on January 14, 2015. ANTHONY R. MARTINEZ / U.S. Navy via AFP - Getty Images, file

The U.S. fired flares and attempted radio communication with the Iranian boats but both were unsuccessful, so the Squall fired a few shots into the water as a deterrent.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The official called the interaction "unsafe and unprofessional."

While Iranian boats frequently come close to U.S. ships in the area, the U.S. rarely fires warning shots, the defense officials said.

It is the second time in less than a week that a U.S. craft and a Iranian vessel have had an encounter.

A U.S. official said four Iranian Revolutionary Guard Corps vessels conducted a high-speed intercept and came within a short distance of the guided missile destroyer USS Nitze despite repeated radio warnings near the Strait of Hormuz on Tuesday. The Nitze attempted radio communications with the Iranian vessels with no response, the U.S. official said.

As two of the vessels sped toward them, the Nitze sounded the maritime danger signal and fired ten warning flares. The Nitze altered course away from the approaching Iranian vessels.

Only after the two Iranian vessels came within 300 yards of the Nitze did the Iranian vessels slow down.

The Nitze and U.S. Naval Forces Central Command assessed the interaction as unsafe and unprofessional.

On Thursday, Iran's defense minister said those Iranian vessels were just doing their job.

"If an American ship enters Iran’s maritime region, it will definitely get a warning. We will monitor them and, if they violate our waters, we will confront them," Defense Minister Hossein Dehghan said in a statement reported by the Iranian Students’ News Agency.

The U.S. asserts that the ships were in international waters at the time.