A British warship trained its guns on three Iranian vessels that tried to block the passage of a U.K.-flagged oil tanker through the Strait of Hormuz, the country’s Defense Ministry said, a confrontation that comes amid heightened tensions between Washington and Tehran.

The three Iranian ships tried on Wednesday to impede the British Heritage as the tanker carrying oil for British oil giant BP PLC traveled from the Persian Gulf through the strait, but were turned away by the HMS Montrose, the ministry said Thursday.

The...