NEW YORK--U.S. oil prices rose to a three-week high Wednesday after weekly government data showed an increase in demand for petroleum products at an unusual time of year.

Light, sweet crude for June delivery settled at $102.37 a barrel, the highest close since April 21. The contract rose 67 cents, or 0.7%, on the New York Mercantile Exchange. Brent crude on ICE Futures Europe settled up 88 cents, or 0.8%, to $110.41 a barrel.

U.S. trading moved largely in response to demand for gasoline, jet fuel and other products made from crude oil, analysts and a broker said. Total demand grew by 895,000 barrels per day last week to 19.4 million barrels per day. About half of that growth came from gasoline, a surprise for May, when demand usually calms before the summer driving season.

"The demand number is off the charts," said Carl Larry, an analyst at Oil Outlooks & Opinions. "Things are a little shaky here about whether we can keep production up to meet demand."

Stockpiles of gasoline and distillates fell, contrary to analysts' expectations of small increases. The amount of gasoline stored in the U.S. was down 800,000 barrels from the previous week to 212 million barrels, compared with an expected rise of 100,000. Stocks of distillates, which include heating oil and diesel, are at 113 million barrels, falling by 1.1 million barrels instead of rising by the expected 600,000 barrels.

The numbers were, however, mixed, and not everyone believed they signaled that prices should go higher. Prices did start to trend down late in the day and after-hours, recently trading at $102.17 a barrel, 20 cents below the closing price.

Production hit 8.4 million barrels a day last week, the highest production since 1987. It pushed stockpiles up by 900,000 barrels during a week when analysts had expected stockpiles to stay unchanged. Stockpiles finished the week with 398.7 million barrels.

"I'm really surprised by the price action today," said Richard Soultanian, co-president of NUS Consulting Group in Park Ridge, N.J. "They're kind of looking at things backwards."

Reformulated gasoline blendstock, or RBOB, for June delivery settled up 3.91 cents, or 1.33%, at $2.9752 a gallon. June diesel rose 1.86 cents, or 0.6%, at $2.9698 a gallon.