Oil prices settled up nearly 6 percent on Wednesday after OPEC sources said the group has struck a deal to limit crude output at its policy meeting in November, its first agreement to cut production since the market crashed two years ago on oversupply.
OPEC will agree to concrete levels of production for country at its Nov. 30 meeting in Vienna, the sources said.
After reaching its group target, it will seek support from non-member oil producers to further ease the global glut, they added.
Brent crude 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 settled up $2.38, or 5.3 percent, to $47.05 a barrel.
The oil rally spilled over into the stock market, with Wall Street's index of energy shares rising 4 percent on track to its best day since January.
"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! 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.
"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. For the Saudis, it just goes against the conventional wisdom of what they've been saying," said Jeff Quigley, director of energy markets at Houston-based Stratas Advisors.
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 became more protective of individual market share. The deal in Algiers follows failed talks in Qatar in April for a production freeze.
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. The drawdown was offset by a 2 million barrel build in gasoline stockpiles, compared with expectations in a Reuters poll for a gain of 178,000 barrels.