NEW YORK (Reuters) - Oil prices settled up nearly 6 percent on Wednesday after OPEC struck a deal to limit crude output at its policy meeting in November, its first agreement to cut production since 2008 and after the market crashed on oversupply.

A pumpjack drills for oil in the Monterey Shale, California, April 29, 2013. REUTERS/Lucy Nicholson

The Organization of the Petroleum Exporting Countries reached agreement to limit its production to a range of 32.5-33.0 million barrels per day (bpd) in talks held on the sidelines of the Sept. 26-28 International Energy Forum in Algiers, group officials told Reuters.

OPEC estimates its current output at 33.24 million bpd.

“We have decided to decrease the production around 700,000 bpd,” Iranian Oil Minister Bijan Zanganeh said.

OPEC will agree to production levels for each member country at its Nov. 30 meeting in Vienna, group officials said. After reaching its group target, it will seek support from non-member oil producers to further ease the global glut.

Brent crude LCOc1 settled up $2.72, or 5.9 percent, at $48.69 a barrel, hitting a more than two-week high of $48.96.

U.S. West Texas Intermediate (WTI) crude CLc1 rose by $2.38, or 5.3 percent, to settle at $47.05, after a peak $47.45, its highest since Sept 8.

The oil rally spilled over into the stock market, with Wall Street's index of energy shares .SPNY rising 4 percent for its best one-day gain since January. [.N]

“This is a historic deal. This is the first time OPEC and non-OPEC will agree together in over a decade. This should put a floor on oil and should see oil move back toward the $60s,” Phil Flynn, analyst at Chicago-based brokerage Price Futures Group.

“The cartel proved that it still matters even in the age of shale!,” Flynn wrote in a market commentary. “This is the end of the ‘production war’ - OPEC claims victory.”

Other analysts saw a selloff down the road, citing OPEC’s general lack of adherence to quotas.

Oil prices have more than halved from highs above $100 a barrel in mid-2014 as surging production from U.S. shale oil combined with other global oversupplies and OPEC output.

As oil traders looked to OPEC to cut output, key members such as Saudi Arabia and Iran resisted, becoming more protective of individual market share even though the rout hurt the group’s oil-dependent economies. The deal in Algiers follows failed talks in Qatar in April for a production freeze.

“This was unexpected for sure,” Scott Shelton, energy broker for ICAP in Durham, North Carolina, said, referring to the deal. “No one that I know of saw it coming. The market doesn’t seem positioned for it. The fundamentals in the U.S. are already tighter than we expected and is due to get tighter.”

Oil prices gyrated earlier in the day after U.S. government data showed a surprise drop in domestic crude stockpiles for a fourth week in a row. [EIA/S]

Jeff Quigley, director of energy markets at Stratas Advisors in Houston, said it was “too preliminary” to get excited over the OPEC deal.

“The devil’s in the details here,” Quigley said. “And for them to say it’s going to start in November is very suspect to me. We don’t know yet who’s going to produce what. I want to hear from the mouth of the Iranian oil minister that he’s not going to go back to pre-sanction levels.”

Before the news of Wednesday’s deal, Iranian’s Zanganeh said the Islamic Republic would agree to curb production “at close to 4 million barrels per day”. Iran’s output has stagnated at 3.6 million bpd since the lifting of Western sanctions.

Michael Cohen, head of energy commodities research at Barclays in New York, was similarly pessimistic.

“Our view is that it is likely that what is going to happen is nothing more than the status quo, in which the Saudis usually reduce their output post-summertime,” Cohen said. “And this is a good way to put a good face on what is likely happening already.”