OPEC and its Russia-led oil-producing allies agreed to unleash millions of barrels of bottled-up crude over the next two years, committing to restore all of the cuts they made at the start of the pandemic as economies pick up and crude demand recovers.

The group agreed to add new oil in modest installments over many months, underscoring the still-uncertain speed of the world’s economic recovery. Much of the developing world, where demand growth for oil had been strongest pre-pandemic, is still fighting surging Covid-19 cases.

The so-called Delta variant, first seen in India, is also being blamed for rising cases in richer nations. Economic activity in many of those countries, including the U.S. and parts of Europe, has taken off powerfully—helping trigger price rises, shortages and supply bottlenecks. Governments there are banking on large-scale vaccinations to keep infections, hospitalizations and deaths at bay.

Sunday’s oil deal calls for the Organization of the Petroleum Exporting Countries and a Russia-led group of big producers to increase production by 400,000 barrels a day each month through the latter part of 2022. The deal seeks to unwind all the cuts the two groups, collectively called OPEC+, agreed to make at the start of the pandemic, when economies were shuttering and demand sputtering.

The deal is “good for consumers in the short term,” said Robin Mills, chief executive of Dubai-based consulting firm Qamar Energy, though he and other analysts expect price pressure to remain as demand builds.

“The market will be tight this summer,” said Giovanni Staunovo, a commodity analyst at Swiss bank UBS.

The group said it would reassess market conditions in December. The deal goes into effect next month.

Early last year, OPEC+ slashed 9.7 million barrels a day of its collective output, equivalent to about 10% of 2019 demand. It has restored about 4 million barrels of that. Sunday’s deal calls for the remainder of those cuts to be unwound through late next year.

In its first 2022 forecasts for the global oil market, OPEC said last week it expects the world’s appetite for crude to rise by 3.3 million barrels a day to average 99.9 million barrels a day next year. That is about the level of demand pre-pandemic.

The prospect of an OPEC deal and a gradual return of supplies had already led to a drop in oil prices, which have recovered strongly this year. Brent, the international benchmark, and West Texas Intermediate have both fallen about 5% in recent days, as hope for an OPEC deal grew. Brent closed above $73 a barrel and WTI finished above $71 a barrel Friday, both off recent, multiyear highs.

The deal is broadly in line with one struck earlier this month. Final agreement had been held up for over two weeks after the United Arab Emirates asked for its production quota inside the group to be reassessed. It was eager to pump more crude than its allotment, after investing heavily in its oil fields.

Saudi Arabia, OPEC’s de facto leader, reached a compromise with the U.A.E. last week, agreeing to eventually boost that quota.

On Sunday, the group also decided to boost other members’ baselines, the estimate of the maximum amount of oil each country is capable of producing. The adjustments go into effect in May 2022. Those technical adjustments would also boost affected countries’ real output since that is based on these baselines.

OPEC said the U.A.E.’s base line would go up by about 332,000 barrels a day. Saudi Arabia and Russia, two of the world’s biggest producers alongside the U.S., will each get their baseline lifted by 500,000 barrels a day. Overall, the group’s estimated production capacity is being upgraded by 1.63 million barrels a day.

The compromise between Saudi Arabia and the U.A.E. patched up for now what had turned into an acrimonious and public spat between two of OPEC’s closest traditional allies. While Saudi Arabia is far and away the bigger producer and regional power, the U.A.E. is one of just a few OPEC members with so-called spare capacity—barrels it can turn on and off quickly.

Write to Benoit Faucon at benoit.faucon@wsj.com and Summer Said at summer.said@wsj.com