The attack was the latest targeting a vessel moving through the narrow mouth of the Persian Gulf, through which a fifth of all oil and natural gas traded once passed in peacetime.