OPEC finally has a deal!

The oil cartel finalized an agreement on Wednesday to cut its overall production by 1.2 million barrels a day.

Crude prices boomed by almost 9% to $49.20 per barrel as investors cheered the long-awaited deal.

The agreement will set OPEC's new production ceiling at 32.5 million barrels a day starting in January. That's down from the 33.6 million barrels a day the group pumped in October.

"We have been able to reach an agreement," said Qatar's oil minister Mohammed bin Saleh al-Sada. "This agreement is out of the sense of responsibility for OPEC member countries, for non-OPEC countries, for the general well-being and the health of the world economy."

Indonesia had decided to suspend its membership of OPEC because it could not agree to the production cut, he added.

The agreement will see most OPEC countries cut their production by around 4.6%. Saudi Arabia, the group's biggest producer, will see its output decline by almost 500,000 barrels a day.

The agreement hinges on the cooperation of major non-OPEC producers, who must also cut their production by a combined 600,000 barrels a day. Al-Sada, who is also OPEC's president, said that Russia had agreed to slash its production by 300,000 barrels a day.

The idea is that a production cut will help boost crude prices, which have already risen from $26 per barrel in February.

The meeting, which was held in Vienna, caps months of fraught negotiations that pitted the cartel's de-facto leader Saudi Arabia against its regional rival Iran.

Iran's production level was a key sticking point in negotiations. Tehran had insisted on keeping its production near 4 million barrels a day, which is the amount it was pumping before sanctions were imposed.

The agreement reached Wednesday allows Iran to ramp up production by 90,000 barrels a day to just below 3.8 million barrels a day. That's a daily boost of 1 million barrels over its 2015 average.

Libya and Nigeria have also been granted an exemption from the cut. Both countries had seen their production drop because of of armed conflict.

Related: It's OPEC vs. Trump on oil

In September, producers achieved a breakthrough and preliminarily agreed to trim output for the first time since 2008.

The tentative agreement sent crude soaring above $50 a barrel -- but the lack of agreement on final details caused investors to worry that the deal may fall through.

Al-Sada as asked during a press conference to address whether OPEC was still a vital organization.

"OPEC is still OPEC," he said. "Today's unity is a very explicit sign about the position of OPEC."

-- Matt Egan and Ivana Kottasova contributed reporting.