By Richard Galpin
BBC News, Moscow
It took last-ditch negotiations between two heads of state, but finally there was a breakthrough and Russia did not carry out its threat to cut gas supplies to Ukraine on Tuesday.
Europe is heavily dependent on Russian gas transported via Ukraine
The announcement was made at a news conference in the Kremlin between Russian President Vladimir Putin and his Ukrainian counterpart Viktor Yushchenko, which took place minutes before the Russian deadline.
Strangely, neither man referred to the dispute in the opening remarks. Instead, it took a question from a reporter for the news that everyone had been waiting for to be revealed.
This is now the third Russian gas dispute involving Ukraine in two years. At the end of 2006, the giant Russian company Gazprom also threatened Belarus.
And these are not just empty gestures, a form of brinkmanship never intended to be implemented.
Quid pro quo?
In its first dispute with Kiev in January 2006, Gazprom did stop the flow of gas for three days, sparking alarm right across Europe, which is heavily dependent on Russian gas transported through a pipeline network running via Ukraine.
The two leaders hailed the talks as "constructive and honest"
So with the deal announced, is this now the end of the affair? Have Russia and Ukraine patched up their differences sufficiently to ensure there will not be a fourth gas dispute in the coming months or years?
Predictably, the two leaders were extremely upbeat about their meeting and the future relationship between their countries.
Besides sorting out the payment of the $1.5bn (£770m) debt owed by Ukraine to Gazprom, which was the immediate cause of this latest dispute, they said they had also agreed on a price for the gas to be sold to Ukraine throughout this year.
In what was perhaps a quid pro quo, President Yushchenko said Ukraine was interested in Russia becoming a member of the World Trade Organisation as soon as possible and would "do its utmost to achieve this".
This is significant because Ukraine itself has just become a member of the WTO and could veto Russia's long-awaited entry into the organisation.
But there was a sting in the tail at the news conference, which came as a surprise and revealed much about the deeper causes of the tensions between the two countries.
Moscow has warned a new arms race is unfolding around the world
Answering a question about Kiev's plans to join Nato, President Putin issued a stark warning to Mr Yushchenko as he sat next to him.
He said that if - as a Nato member - Ukraine accepted military bases on its soil or allowed parts of a missile defence system to be deployed on its territory, then Russia might respond by targeting its own missiles on Ukraine.
The government in Kiev hopes to take the first formal step towards Nato membership at the alliance's summit in Bucharest in April.
For Moscow this is unacceptable.
It is already furious with Nato for absorbing many Eastern European countries which had previously been within Russia's sphere of influence.
Moscow fears it is being encircled. And that fear would only be heightened by the absorption of Ukraine and another prospective Nato member, Georgia.
Some analysts say it is no coincidence that this latest gas dispute between Russia and Ukraine erupted just a few weeks after the Ukrainian government wrote a formal letter to Nato about its application for membership.
In fact, critics point to the timing of all three gas disputes with Ukraine.
The first - in 2006 - came in the wake of the Orange Revolution which swept away the pro-Russian government and instead brought to power President Yushchenko, who is determined to move Ukraine into the Western orbit.
The second dispute - in October last year - followed a snap election in Ukraine which enabled another veteran of the Orange Revolution, Yulia Tymoshenko, to become prime minister again.
Gazprom insists the disputes are purely commercial and have nothing to do with politics.
It says the price rises it has imposed in recent years on neighbouring countries were to be expected, as it could not continue Soviet-era subsidies.
And of course it has to chase unpaid bills, especially if they amount to more than $1bn.
But it is becoming increasingly difficult to believe that this is the only explanation.
Gazprom is a state-controlled company and its chairman is Dmitry Medvedev, the current deputy prime minister who is widely expected to become president of Russia after elections in March.
As the world's largest gas company, it is potentially a very powerful tool of Moscow's newly assertive foreign policy.
Not only does Gazprom control a third of global gas reserves, it has also been buying up stakes recently in many of the pipeline networks upon which Europe depends for its energy needs.