Ukraine, Russia and the European Union signed a deal on Thursday on the resumption of Russian natural gas supplies to Ukraine for winter after several months of delay during the conflict in Ukraine.
European Commission President Jose Manuel Barroso, who witnessed the three-way signing ceremony in Brussels as he prepares to leave office on Friday, said: "There is now no reason for people in Europe to stay cold this winter."
Talks had been broken off in the early hours as Moscow sought more guarantees from the EU that it would help Ukraine pay for its natural gas. They resumed on Thursday evening.
EU officials said both Russia and Ukraine had bargained hard for commitments from the Western bloc, with Moscow looking for EU cash to help Ukraine pay off debts to Gazprom and the Kiev authorities anxious to get a deal that they could present to domestic voters as not overpaying for vital Russian supplies.
Ukrainian Prime Minister Arseny Yatseniuk said in Kiev that the EU had agreed to serve as guarantor for Kiev in holding Russia to an agreement, notably on the price Ukraine would pay.
Yatseniuk, in figures later confirmed by Moscow, said Ukraine would pay $378 per 1,000 cubic metres to the end of 2014 and $365 in the first quarter of 2015.
He said Kiev was ready to pay off debts for gas immediately after any deal was signed.
A total of $1.45 billion would be paid immediately and a further $1.65 billion paid by the end of the year, he said.
Russian Energy Minister Alexander Novak insisted that Ukraine would still have to pay up front for new deliveries to see its 45 million people through winter. Moscow expects some $1.6 billion for gas to be supplied.
Some critics of Russia question whether its motivation is financial or whether prolonging the wrangling with ex-Soviet Ukraine and its Western allies suits Moscow's diplomatic agenda.
Ukraine is in discussions with existing creditors the EU and the IMF.
The gas cut-off has had little impact for months. But pressure is mounting for a deal as temperatures start to drop below freezing.
European Energy Commissioner Guenther Oettinger, who has been mediating, also leaves office on Friday, making way for a new European Commission.
"We can say to the citizens of Europe that we can guarantee security of supply over the winter," he said of what he called the $4.6-billion deal to supply Russian natural gas to Ukraine.
EU member states west of Ukraine would also, he said, have stable supplies, passing through Ukrainian pipelines, while Russia would gain the benefit of payment for its energy.
The two sides came close to an agreement in September, but last week differences were wide.
Weekend elections returned a pro-Western parliament in Kiev, potentially stoking tensions with Moscow, although Russia's EU envoy, Vladimir Chizhov, said on Thursday the mood could be more relaxed now the vote had taken place.
Ukraine's Naftogaz company has set aside $3.1 billion in a special escrow account to pay the debt.
Kiev says it is working to raise more money from all possible sources of financing, including the EU. The Commission is considering Ukraine's request, made last week, for a further loan of 2 billion euros.
Russia provides around a third of the European Union's natural gas, roughly half of which is pumped via Ukraine.
Ukraine in turn relies on Russia for around 50 percent of its own natural gas and despite storage has a winter shortfall of around 3 billion to 4 billion cubic metres, depending on the weather.
For Russia, the natural gas sector contributes approximately a fifth of the national budget.
Sanctions on Russia, which EU officials decided to leave unchanged on Tuesday while the conflict in Ukraine continues, are sapping an already weak economy.