Oil held a gain as the war in the Middle East dragged on, with Iran confirming the death of its security chief in another intensification of the conflict that’s roiled energy markets.