New York Oil surged on Friday in heavy trading to the fourth biggest daily gain on record, as a deal by European leaders to shore up euro zone banks triggered frantic short-covering by funds that had been riding crude's price collapse over the last quarter.

Despite the sharp gains, both international benchmark Brent and US oil futures posted their biggest quarterly declines since the fourth quarter of 2008 due to weak demand, ample supply and economic worries.

Oil's gains for the day came as part of a wider market rally, with the euro and world stocks rising after euro zone leaders agreed on measures to cut soaring borrowing costs in Italy and Spain and recapitalise regional banks.

Brent crude oil futures rose more than $6 a barrel to near $98 while US crude jumped by more than $7 to settle just below $85 a barrel -- the fourth largest daily gains in dollar terms since the contracts were launched.

Crude drew further support from a strike in Norway that cut production of oil and natural gas liquids by 230,000 to 250,000 barrels per day, or up to 13 per cent of the capacity of the world's No. 8 crude exporter.

"The NYMEX just went wild. It never looked back. Just up, up and away." said John Troland, an independent energy advisor in Houston, referring to the New York Mercantile Exchange where benchmark US crude oil futures trade.

Throughout the second quarter, hedge funds and other speculators had bet big on lower oil prices. Speculators cut their net long positions by more than half over the quarter, according to data from the US Commodity Futures Trading Commission.

In addition to mounting euro zone worries, oil prices came under pressure in recent months from weaker demand and swelling global inventories as Saudi Arabia boosted output to quell concern about the drop in exports from sanction-hit Iran.

"We had significant second-quarter trends that may all be in the process of reversing, including the risk off trade triggered by the EU instability," said Tim Evans, energy analyst for Citi Futures Perspective, adding oil demand is normally seasonally stronger in the second half of the year.

"What has changed today is the market sentiment, the fundamentals may evolve at a more glacial pace."

Brent crude oil rose $6.44 to settle at $97.80 a barrel, a gain of 7.05 per cent and the biggest one day rise since April 2009. Brent started the second-quarter at $122 a barrel.

US crude rose $7.27 to settle at $84.96 a barrel, a gain of 9.36 per cent - the biggest since March 2009. US crude started the second-quarter at $103 a barrel.

Brent volume was almost 20 per cent above the 30-day average, while US crude futures saw turnover 36 per cent above the 30-day average.

Front-month US July RBOB gasoline rallied 4.3 per cent while heating oil surged 5.7 per cent. Both contracts expired on Friday.

The euro zone optimism swept across commodities markets, with the Thomson Reuters-Jefferies CRB index up about 3 per cent.

Analysts said Friday's move could portend stronger fundamentals for oil for the rest of the year as sanctions against Iran cut the OPEC member's output.

"Given it's the last day of the quarter we might be seeing some rebalancing and short-covering (by funds) after the falls we've seen," said Katherine Spector, commodity strategist at the Canadian Imperial Bank of Commerce in New York.

"The supply-and-demand balance looks better for the second half of this year, so we expect to see prices move higher from here. We think there will be further reductions in Iran's exports and at the same time other members of the Orgnisation of Petroleum Exporting Countries (Opec) are likely to reign in production slightly."

OPEC's oil output has remained close to its highest since 2008 in June as extra oil from Saudi Arabia and Iraq has compensated for a drop in Iranian supply to its lowest level in more than two decades, a Reuters survey found on Friday.

US and European sanctions, designed to target Tehran's disputed nuclear programme, have pushed Iran from second-largest producer in Opec to now rank third behind Iraq. Iran's crude is subject to a European Union embargo starting on July 1 that also bars EU insurance firms from covering Iran's exports.

Saudi Arabia, Opec's largest producer, has increased its output to 10.1 million bpd to help make up for the shortfall from Iran.