OPEC is finally agreeing to cut oil production.

It would be the first time in eight years that the oil cartel would lower output. The agreement was reached on Wednesday at a meeting in Algiers.

Oil prices surged more than 5% in reaction.

A global glut of oil supply caused oil prices to crash over the last two years. And OPEC nations, led by Saudi Arabia, have refused to lower production until now.

Under the agreement, OPEC oil production is expected to be reduced to a range of 32.5 to 33 million barrels of oil per day from 33.4 million. Saudi Arabia, the largest oil producer, is expected to give up 350,000 barrels a day, according to a senior OPEC source quoting the final proposal. Other OPEC nations are expected to lower production too, though more details were not immediately clear.

Three countries are exempted from the production cuts: Iran, Nigeria and Libya. Economic sanctions were lifted on Iran earlier this year, and Libya and Nigeria have had some of their oil facilities damaged by terrorist attacks in recent months.

Oil prices were as high as $100 a barrel in mid-2014. But the global oversupply caused prices to plunge to as low as $26 a barrel in February. The volatility in oil caused stock markets to dive at the beginning of 2016.

In recent months, oil prices have rebounded a bit and oil is currently hovering near $47 a barrel.