Iranian naval boats made dangerous maneuvers around United States warships in the Persian Gulf area on at least four occasions this week, Pentagon officials said Thursday, including one episode in which the Americans fired warning shots from a 50-caliber deck gun to prevent a collision.

It was unclear whether the confrontations — one near the Strait of Hormuz on Tuesday and three in the northern Persian Gulf on Wednesday — were deliberate efforts to send a hostile message about American naval activity.

Still, they underscored the risk of an armed clash between Iran and the United States in an area that has been a perennial source of tension for the two countries.

There was no immediate comment from Iran about Wednesday’s encounters. But its defense minister denied that Iranian vessels had done anything wrong in the Tuesday episode and accused the Americans of trespassing to provoke a response.