The news triggered an immediate spike of more than five percent on oil markets, which had expected the talks in Algiers to end without agreement, and helped push US equities higher.
At the end of six hours of negotiations and weeks of horse trading, OPEC announced the plan to cut production to a level of 32.5-33 million barrels per day (bpd) from 33.47 billion, bpd in August, the International Energy Agency said.
"We have had a very lengthy but historical meeting in Algiers," said Qatari energy minister and OPEC meeting president, Mohammed bin Saleh al-Sada, who confirmed the planned cut.
There are "very positive signs in the market... nevertheless we need to bring forward rebalancing of the market," he told a press conference after the informal talks.
Brent North Sea crude for November delivery rose $2.72 to $48.69, while a barrel of West Texas Intermediate (WTI) was up $2.38 at $47.05 after the announcement.
The meeting agreed to establish a committee to determine how the cut will be shared between members and the quotas will be discussed at OPEC talks in Vienna on November 30.
The committee will also hold talks with non-OPEC countries, including Russia, the second-biggest producer of crude oil.
Moscow has already voiced support for a freeze on its production levels, which hit a new record this month.
' Historic decision'
"Today OPEC has taken a historic decision," said Algerian Energy Minister Noureddine Boutarfa, adding that the move had been agreed unanimously.
"OPEC will go back to its role of monitoring the market. It's a role that it lost many years ago."
Faced with new competition from US shale production, the 14-nation cartel had adopted a more defensive strategy, opening up its taps and cutting prices.
Analysts said the output cut, though a surprise, would not fundamentally change the market.
"Even if one was agreed this would be unlikely to support prices beyond any brief sentiment-driven rally," Capital Economics analysts' group said before the decision was announced.
"Almost all the OPEC members and Russia are already producing very near or at their maximum capacity".
Iran's Oil Minister Bijan Namdar Zanganeh also hailed the agreement, while stressing that Tehran hopes to bring its own production back up to the level of around 4 million bpd it enjoyed before international sanctions over its nuclear programme were imposed.
Record low prices
Wednesday's meeting was tasked with addressing the collapse in prices, which have fallen by more than half since mid-2014.
"We must act on supply to re-stabilise the market" which has been hit by massive oversupply, Boutarfa, the Algerian energy minister, told a news conference.
According to the International Energy Agency, last year saw a 25 percent fall in investment in oil and gas exploration and production and the agency says the decline is continuing apace.
Amid record output, there has been discord among the 14-nation cartel, whose share of global crude supply is around 40 percent.
Progress has been hampered notably by disagreements between Saudi Arabia and Iran, the latter back on stream after the recent lifting of a range of energy-related sanctions.
OPEC kingpin Saudi Arabia has so far refused to curb its output at a time when Iran is ramping up production.
Saudi Arabia and Iran, the Middle East's foremost Shiite and Sunni Muslim powers, are at odds over an array of issues including the wars in Syria and Yemen.
But there had been some tentative signs of a narrowing of differences in Algiers, where Russia also joined the talks on Wednesday.
A previous bid to freeze output fell apart in Doha in April as Iran refused to take part, saying it needed to return output to its pre-sanctions levels.
Further complicating the negotiations, Libya and Nigeria have also been reluctant to limit production after conflicts that have curbed their output.
Prices plunged from peaks of more than $100 a barrel in mid-2014 to near 13-year lows below $30 in January, before recovering some of the losses.