When the Organization of the Petroleum Exporting Countries met in Vienna in December, it was in danger of imploding.

Oil prices had plunged. Member states Iran, Venezuela and Libya were refusing to cut production. Qatar had quit. And U.S. President Trump was pressuring Saudi Arabia to keep prices low.

With negotiations teetering on the brink of failure, rescue came from an unlikely place—Russia, which isn’t even an OPEC member. President Vladimir Putin agreed to cut Russian oil production in league with OPEC, provided that Iran was allowed to keep pumping.

The degree of acrimony that pervaded that critical meeting, and the critical role Russia played in resolving the crisis, hasn’t previously been reported. What happened behind closed doors in December was a pivotal moment in Russia’s transformation from a nation that didn’t cooperate with OPEC at all to one that has become an indispensable partner.

As the cartel of big oil producers has lurched from crisis to crisis—crashing prices, regime changes in member countries, cartel infighting, frequent attacks by Mr. Trump—Russia has wielded its power as a major oil producer to help. That has given Mr. Putin considerable influence over the direction of the world’s $1.7 trillion crude-oil market, and more power in the Middle East.