By Christian Berthelsen and Georgi Kantchev 

Oil futures soared Friday as surging markets for refined gasoline and diesel helped drive crude higher, with traders looking past a fall in U.S. drilling activity that was more modest than expected.

The benchmark U.S. oil contract gained $1.59 or 3.3% to settle at $49.76 a barrel on the New York Mercantile Exchange. The global Brent contract rose $2.53 or 4.2% to settle at $62.58 a barrel.

Oil-field services company Baker Hughes Inc. said its count of rigs drilling for oil in the U.S. fell by 33 this week to 986, slipping below 1,000 for the first time since June 2011. Though that number is down 31% from a year ago, the weekly decline fell short of what analysts said would be necessary to have a substantial effect. Research consultancy Ritterbusch and Associates said the weekly count would have to fall by at least 50 to affect the market.

Investors in recent months have been fixated on the number as an indication of eventual supply cuts, though analysts caution a reduction in the number of U.S. oil rigs in use doesn't immediately translate to a fall in output, which is currently running at a multiyear high of 9.3 million barrels a day.

Oil futures, which had been positive throughout the session, gave back some gains after the report's release. But the market rallied again in the last half-hour of trading, following prices higher for refined fuel products such as gasoline and diesel. Contracts for both products rallied Friday, in advance of their expiration with the close of trading.

"It's expiry madness," said Phil Flynn, account executive at wholesale brokerage Price Futures Group in Chicago. "Crude oil is basically being supported by those products."

Oil markets have been whipsawing in recent weeks with investors weighing signs of impending supply cuts and improving demand against indications of continuing global oversupply. The market has arrested the steep fall that prevailed from June to late January but remains volatile as traders assess whether the market rout is over. Brent, the global price benchmark, is up more than 13% in February while U.S. crude is broadly flat for the month.

Analysts caution the relative stabilization in the market masks weakness, with the global oversupply of oil continuing to grow and demand coming from temporary factors such as storing for later sale at a higher price rather than real-world use.

"The recent strength in oil prices is likely temporary and hides huge uncertainties with respect to the fundamental balance of the market," Barclays said in a note. Even accounting for the recent falloff in production from Libya, the bank estimated the glut would continue to grow at a pace of 1.2 million to 1.3 million barrels a day.

Still, there are some emerging signs of stabilization. A Reuters survey of shipping data and oil companies found that oil output from the Organization of the Petroleum Exporting Countries fell in February, as bad weather in southern Iraq delayed tanker loadings and sailings. The estimated output of 29.92 million barrels a day was lower than the cartel's official target of 30 million barrels a day and the lowest level since last June, when the market collapse began.

Oil prices might still drift lower in the short term as supply-side support to prices wanes in the weeks to come, JBC Energy said.

"Iraqi shipments for March should see a considerable lift as several February cargoes are deferred into March with plenty of vessels already in place to haul the crude. In the same vein, basically all onshore production in Libya was shut in following the sabotage of a key pipeline. Thus, it seems likely that any potential production and export volume changes will be to the upside," analysts at JBC wrote in a note.

China's official manufacturing PMI number is expected over the weekend, and market observers expect it to stay below the threshold of 50, indicating contraction. The data could have ripple effects in the market next week, as China is the world's second-largest oil consumer after the U.S. and a key driver of demand growth.

March gasoline futures rose 6 cents or 3.5% to settle at $1.7676 a gallon on the Nymex. March diesel futures rose 16.31 cents or 7.6% to settle at $2.2989 a gallon.

Write to Christian Berthelsen at christian.berthelsen@wsj.com and Georgi Kantchev at georgi.kantchev@wsj.com

Subscribe to WSJ: http://online.wsj.com?mod=djnwires