"They were able to avoid a serious incident by following the procedures that we use," said Commander Lydia Robertson, a spokeswoman for the US Navy's Bahrain-based Fifth Fleet.
The Westward Venture, a cargo ship chartered by the US Department of Defense, was traveling north in international waters in the central Gulf at around 8 am local time on Thursday when the incident took place, Robertson said.
The ship was approached by two unidentified small boats and its crew issued "standard queries" to the vessels by radio but did not receive a response, she said. The ship then fired a flare, which also produced no response, she said.
The boats continued to approach the cargo ship and its onboard security team fired "a few bursts" of machine gun and rifle warning shots, Robertson said.
"The small boats left the area a short time later," Robertson by telephone.
A US defense official, speaking on condition of anonymity, said the boats were believed to be Iranian.
Shortly after the incident, the ship received a radio query from a ship identifying itself as an Iranian coast guard vessel, Robertson said.
"It is not clear if this was one of the small boats or a separate boat," she said. She said the query from the vessel was conducted correctly.
The United States said in January Iranian boats threatened its warships on Jan. 6 along a vital route for crude oil shipments.
Iran denies incident, oil prices jump
Meanwhile Tehran has denied there had been any confrontation between its forces and the US, Iranian media reported.
Some media suggested that, if there had been an incident, it may have involved a private boat that could have been Iranian.
"There has been no confrontation between Iranian boats and US military vessels in the Persian Gulf," the state-owned English-language satellite channel Press TV reported on its website, citing a source in Iran's Revolutionary Guards.
Oil prices surged more than $3 a barrel on Friday as a result of the reported incident, which also drove
down US stocks.Light, sweet crude for June delivery jumped as high as $119.55 on the news before retreating to trade up $3.08 at $119.14 a barrel on the New York Mercantile Exchange.
On Friday, oil prices were already up before the report on news of a pipeline attack in Nigeria and a looming refinery strike in Scotland.