Gasoline inventories dropped 3.5 million barrels, contrary to expectations for an increase.
Demand for gasoline was about 2 and a-half percent below where it was a year earlier.
Inventories of distillate fuel, which include diesel and heating oil, rose 2.4 million barrels. That is a bigger-than-expected increase.
In midday trading, light, sweet crude for August delivery rose 39 cents to $122.58 a barrel on the New York Mercantile Exchange.