Ukraine and Russia have reached an agreement over Kiev's huge unpaid gas bill, Russian President Vladimir Putin has said.
It is the two countries' second such gas dispute in two years
Mr Putin was speaking after urgent talks with his Ukrainian counterpart Viktor Yushchenko in Moscow.
For his part, Mr Yushchenko said that from Thursday Ukraine would start repaying its debt to Russia's Gazprom.
Russia earlier threatened to switch off supplies at 1500 GMT if Kiev had not paid its $1.5bn (£770m) gas bill.
Ukraine had disputed the bill, saying it was just over $1bn.
Warning to Nato
Speaking at a joint news conference, President Putin said Russia's state-run gas monopoly Gazprom had accepted Ukraine's proposals at the talks.
"We have heard that the settlement of the debt will begin shortly," Mr Putin said.
Moscow's ties with pro-Western Ukrainian PM Tymoshenko are cool
"A working group should be set up in the next few days to map out direct, transparent relations for the market and [gas] deliveries," he said.
President Yushchenko confirmed that the deal had been reached, saying Ukraine would start paying off its debt on Thursday.
The BBC's Richard Galpin in Moscow says the crux of this latest crisis seems to be over how the bill is to be paid.
Ukraine's pro-Western Prime Minister Yulia Tymoshenko wants the money paid directly to Gazprom, rather than going through an intermediary company - RosUkrEnergo - which she views with deep suspicion.
Both leaders described the talks as "constructive and honest", stressing that Ukraine and Russia would always be strategic partners.
However, President Putin warned that there would be consequences if Ukraine joined the Nato military bloc - a goal publicly stated by Mr Yushchenko.
Before the talks, Gazprom had said the gas row would not affect supplies to the rest of Europe.
But as most of the company's gas supply to Western Europe passes through Ukraine, concerns remained that the row could escalate into a repeat of the supply interruption that happened two years ago.
In January 2006, gas shipments to Europe were disrupted after Russia halted fuel supplies to Ukraine for several days amid a fierce argument over price hikes.
Although Gazprom claims the current dispute is purely commercial, fears have been raised that Moscow might be exploiting its energy resources to exert political pressure on its neighbours.
Our correspondent says Moscow does not like President Yushchenko or his prime minister.
Both were leaders of the Orange Revolution three years ago that swept away a pro-Russian government in Ukraine and replaced it with one that looks to the West for support and now wants to join Nato.