The US military attacked Iran on Friday in response to an Iranian drone strike on a cargo ship in the Strait of Hormuz, with each country accusing the other of violating terms of a ceasefire agreed on last week.