Oil closed above $71 a barrel on Friday, buoyed partly by strong gains in gasoline futures in New York.
Prices had earlier hovered below the $70 a barrel mark, weighed down by worries about a possible U.S. slowdown and after Mexico's Gulf oil rigs suffered only minor damage from Hurricane Dean.
U.S. light, sweet crude for October delivery was higher after gaining 57 cents on Thursday, ending a three-day losing streak that had knocked prices to their lowest since late June.
London Brent crude for October also rose.
Brent crude had moved to a premium over U.S. crude on Thursday for the first time since July 27 following a rise in crude oil stockpiles in the United States last week.
A sudden surge in crude followed an early advance in gasoline as energy markets opened in New York.
U.S. gasoline was up more than 2% at $1.9694 a gallon on the New York Mercantile Exchange.
"Gasoline is pushing up crude here," said Phil Flynn, analyst at Alaron Trading. "I also think gasoline had been oversold lately."
A shut-down at a gasoline-making unit at an oil refinery in Big Spring, Texas due to an equipment malfunction also helped boost gasoline.
Oil has been sensitive to weakness in world stock markets caused by concerns over the impact of troubles in the U.S. mortgage market on the wider economy.
But European equity markets reversed early losses as U.S. stocks rose after publication of encouraging data on the U.S. economy.
U.S. government statistics showed new home sales rose unexpectedly in July and new orders for manufactured goods were up much more than expected.
But financial markets remain nervous about further fall-out from the U.S. mortgage problems that could hurt consumer confidence.
"The expectation that the U.S. will slow was there before," said Frances Hudson, investment director at Standard Life Investments.
"The question for most people is if the U.S. slows, how much can other places be insulated from it, can the real economy continue to make progress."
Bullish Factors Remain
She said economic development in China, the world's second biggest oil consumer after the United States, would carry on and other factors that have boosted oil this year remain.
"We've still got all the political worries about the Middle East, the energy security concerns still haven't gone away and these will continue to underpin it, plus what happens with the weather."
Oil hit a record high of $78.77 a barrel on Aug. 1, but financial market turmoil caused by the U.S. mortgage sector problems has pushed it lower.
The U.S. mortgage crisis has spread to other markets in recent weeks and oil has been hit as investors, fearing a credit squeeze, have sold to raise cash.
Prices have fallen further since Hurricane Dean turned out to be less of a threat to Gulf of Mexico oil installations than originally feared.
Mexico's Gulf oil rigs have already restarted production in the Bay of Campeche in the aftermath of the hurricane.
State energy monopoly Pemex, one of the top three oil suppliers to the United States, produced 342,000 barrels of crude oil in the region on Thursday.