U.S. gas prices rose above $4 per gallon as the Iran war drove oil costs higher, with state averages varying widely.