Iran seized a British oil tanker after one of its vessels was detained.

The United States staged a secret cyberattack in June against a database used by Iran's Islamic Revolutionary Guard Corps to plot attacks on oil tankers in the Gulf, The New York Times reported.

The newspaper, quoting senior US officials, said the June 20 attack had degraded the ability of Iran's paramilitary force to target shipping in the Gulf.

It said Iran was still trying to recover information and restart military communications networks and other systems knocked offline.

The Times said the cyberstrike was the latest in an ongoing cyberconflict between the United States and Iran.

It said the cyberattack went ahead after President Donald Trump had called off a retaliatory military airstrike against Iran for shooting down a US drone.

The newspaper said the White House viewed the cyberattack as a proportional response to the destruction of the unmanned drone.

It said the database targeted in the attack was used by the Guards to choose which tankers to target.

No tankers have been targeted since the June 20 operation although Iran did seize a British oil tanker after one of its vessels was detained, the Times said.

US Defense Secretary Mark Esper urged Iran on Wednesday to enter into discussions with the United States in order to ease tensions in the Gulf region.

"We are not seeking conflict with Iran. We want to engage with them diplomatically," Esper said in his first formal press conference after being confirmed last month.

Breaking with his predecessor Barack Obama, Trump enacted a policy of "maximum pressure" on Tehran over its disputed nuclear program and last year unilaterally withdrew from the landmark 2015 international deal that placed limits on Tehran's nuclear activities.

Tensions over that move have gradually risen, with Iran seizing tankers in the Gulf in recent months and Britain detaining an Iranian tanker off of Gibraltar.