Nearly a week after negotiations collapsed amid accusations of blackmail, sabotage and thievery, both Moscow and Kiev claimed victory.
The complicated, five-year deal involves a complex pricing plan, gas from Central Asia and a Russian-Swiss trading business that has been under investigation in Ukraine.
"Two nations won, Russia and Ukraine; Europe won; it is common sense that won," Ukrainian Prime Minister Yuriy Yekhanurov said in the Ukranian capital Kiev.
Analysts mixed
Russian President Vladimir Putin said the deal would reflect positively on the whole range of relations between Moscow and Kiev by creating "stable conditions for deliveries of Russian energy carriers to our Western European partners many years into the future."
Analysts, however, had mixed reactions to the deal, which sees Ukraine buying gas from the RosUkrEnergo trading company for nearly twice what it had previously been paying, but still far lower than the fourfold increase Russia had demanded.
The deal is "a very powerful blow which threatens Ukraine with catastrophe," said Mykhaylo Pohrebinsky, a Kiev-based analyst.
Chris Weafer, chief strategist with Alfa Bank in Moscow, called it a "face-saving compromise" for both countries but he blamed Russia's state-controlled gas monopoly, OAO Gazprom, for the impasse.
"What started out as a commercial dispute turned into a political dispute, because it was badly handled," he said.
The heads of Gazprom and the Ukrainian state-controlled company Naftogaz announced the deal in Moscow on Wednesday, three days after Russia stopped gas deliveries to Ukraine and two days after European customers reported a sharp drop-off in their own gas supplies, which cross Ukraine.
Under the complex deal, Gazprom will sell gas to RosUkrEnergo for the same price it had demanded Ukraine pay beginning January 1 - US$230 (euro195) per 1,000 cubic meters.
Ukraine will then buy gas from the company for US$95 (euro80) -nearly twice what it had previously been paying Gazprom.
Sole gas provider
The deal also makes RosUkrEnergo the sole provider of gas to Ukraine.
Little is known about RosUkrEnergo, however, except that it is owned by a Gazprom bank and a Swiss subsidiary of Austria's Raiffeisen Bank.
Wolfgang Putschek, a member of the executive board of Raiffeisen Invest, said Centragas was acting as custodian for "a group of international investors in the gas business."
No one answered the repeated phone calls to RosUkrEnergo's offices in Zug, Switzerland.
RosUkrEnergo last summer was under investigation by Ukraine's state security agency, which was also probing Naftogaz and groups affiliated with Semyon Mogilevich, a Ukrainian-born Russian citizen and reputed organized crime figure who is wanted by the FBI.
Mr Putschek said "the whole criminal investigation is complete nonsense," and that all claims of wrongdoing were "politically driven" by former Prime Minister Yulia Tymoshenko, now a key opposition leader, and her ally Oleksandr Turchinov, the former head of the security agency.
The two companies also agreed on a 47 percent increase in the transit fee Gazprom pays to Ukraine to send its gas through the pipelines - to US$1.60 (euro1.35) per thousand cubic meters to travel 100 kilometers.
Ukraine will also pay cash for gas deliveries and Russia will pay cash for transit, Gazprom spokesman Sergei Kupriyanov said, ending a barter system that had displeased Russia.
RosUkrEnergo can pay and charge the different prices because it also buys gas from the Central Asian nations of Turkmenistan,
Uzbekistan and Kazakhstan that will be added to the mix, Kupriyanov said.
According to Ukrainian President Viktor Yushchenko, Turkmen gas sells for about US$50 (euro42) per 1,000 cubic meters.
Win for Russia
Overall, the deal appears to be a greater win for Russia.
Ukraine will remain subject to market prices and also Turkmenistan's idiosyncratic president, Saparmurat Niyazov, who has been trying to raise his country's gas prices.
Turkmenistan is Ukraine's main gas provider, but its gas runs through Russian pipelines.
Mr Kupriyanov said that the agreed price for Russian gas was US$230 as of January 1 but that it would fluctuate with the market.
He did not indicate how often the price would be adjusted.
Among the consequences of the deal will be greater effort in Ukraine to modernise the country's energy-inefficient industries: "We will do everything possible to sharply reduce gas consumption," Mr Yekhanurov said.
The gas dispute was the most dramatic clash yet between Kiev and Moscow, whose relations chilled markedly following the 2004 Orange Revolution protests that brought the pro-Western opposition leader Viktor Yushchenko to power.
Beyond a bilateral dispute, however, were the implications for
Europe, which gets about a quarter of its gas from Russia, some 80 percent of that arriving in pipelines that cross Ukraine.
In addition to harming Russia's reputation as a reliable energy supplier, the spat also gave Moscow a black eye as it assumes the chairmanship of the Group of Eight major industrialized nations - a position Moscow wants to use to boost its international prestige.
EU gas pipeline
Meanwhile European Union gas experts meeting in Brussels have agreed to consider the construction of a pipeline from the Adriatic Sea towards central Europe in order to reduce dependence on Russian gas.
"The idea of an alternative gas transportation system is already being discussed at the European Union level," Hungarian Economy Minister Janos Koka told MTI national news agency.
Mr Koka said the proposal to build the pipeline north from a port on the Adriatic was backed by Austria, Hungary, Slovenia and non-EU member Croatia.
A Hungarian economy ministry spokesman said tankers could transport liquid gas to the port from several regions, including North Africa and the Middle East.
Mr Koka said the next step was to conduct a feasibility study on the pipeline, to be completed by the end of March, and then work out financing details.
The gas experts held an emergency meeting in Brussels on Wednesday following a gas price dispute between Russian and Ukraine that affected gas supplies to Europe.
The EU imports more than 40 percent of its natural gas, and around half that amount comes from Russia, but some parts of central and eastern Europe depend on Russia for nearly their entire gas supply.
