By Nicole Friedman 

NEW YORK--Oil prices rose Wednesday on unexpected declines in U.S. crude-oil supplies and production.

Prices have slumped this month on renewed fears that the global glut of crude oil could last longer than investors initially expected. This comes as production in the U.S. and elsewhere continues to exceed consumption.

Wednesday's data offered some hints that the oversupply of crude oil is starting to shrink, but analysts warned that the trend might not continue and prices could resume their decline.

Light, sweet crude for September delivery settled up 81 cents, or 1.7%, to $48.79 a barrel on the New York Mercantile Exchange. Brent, the global benchmark, rose 8 cents, or 0.2%, to $53.38 a barrel on ICE Futures Europe.

Domestic crude inventories fell by 4.2 million barrels to 459.7 million barrels last week, the U.S. Energy Information Administration said Wednesday. Analysts surveyed by The Wall Street Journal expected stockpiles to be unchanged in the week.

Though refineries processed less crude into gasoline and other fuels compared with the week before, crude-oil inventories still declined due to a drop in imports and production.

U.S. crude-oil production fell by 145,000 barrels a day to 9.4 million barrels a day, the largest one-week decline since October 2013. Excluding Alaska, which saw a small rise in output, the drop totaled 151,000 barrels a day.

"The most interesting thing is the pretty big adjustment downward in crude production," said Dominick Chirichella, analyst at the Energy Management Institute. "In general, I think it's an overall positive report."

The EIA's weekly production figures are based on a statistical model, not reported production.

Prices erased some of their gains late in the trading session as the dollar strengthened on signals from the Federal Reserve that U.S. short-term interest rates could rise in the coming months. A stronger dollar can weigh on crude prices by making the dollar-priced commodity more expensive for foreign buyers.

Gasoline stockpiles fell by 400,000 barrels. Analysts had expected gasoline supplies to be unchanged. Gasoline futures rose 1.92 cents, or 1.1%, to $1.8224 a gallon.

Diesel supplies rose by 2.6 million barrels, more than the 1.3-million-barrel increase that analysts had expected. Diesel futures fell 0.61 cent, or 0.4%, to $1.5983 a gallon.

Write to Nicole Friedman at nicole.friedman@wsj.com