Oil advanced after a tanker carrying Qatari crude was hit during a flare-up in attacks between the US and Iran, straining a ceasefire and hampering shipping through the Strait of Hormuz.