MOSCOW — Russia and Ukraine signed an agreement on Monday to resolve their dispute over the price of natural gas and the terms of its transit across Ukraine to Europe, and said they would quickly resume shipments of fuel to freezing homes and idled factories.

After previous agreements collapsed, officials in Europe had been cautious about the deal negotiated over the weekend between the countries’ prime ministers, Vladimir V. Putin of Russia and Yulia V. Tymoshenko of Ukraine, which was made formal in a ceremony here on Monday.

In a hopeful sign, however, Mr. Putin said that Gazprom, the Russian gas monopoly, had been ordered to turn the gas back on, for Ukraine’s internal market and for re-export. “I hope transit supplies in the European direction will be fully resumed in the nearest future,” he said.

Ukrainian officials have said that once shipments to the border resumed, restoring pressure in the pipelines for export elsewhere in Europe would require about 36 hours.

As it played out over three cold weeks, the gas shutoff left hundreds of thousands of homes in southeastern Europe without heat and shuttered hundreds of factories.

Slovakia, alarming its neighbors, had proposed restarting an obsolete nuclear reactor to make up for the gas shortfalls.

Yet tensions remain between Russia and Ukraine. On Monday, Russia’s president, Dmitri A. Medvedev, signed an order imposing sanctions on countries that sold weaponry to Georgia, the former Soviet republic that Russia fought in August.

The sanctions would halt military and technical cooperation with such countries. Ukraine has sold weaponry to Georgia and could be harmed by the measure, since its military industry is closely entwined with Russia’s as a legacy of the Soviet Union.

But in a sign of some softening of disagreement, at least over the gas business, the two prime ministers complimented each other graciously after the signing — a rarity in their relations.

“I would like to thank the Ukrainian prime minister, Yulia Vladimirovna Tymoshenko,” Mr. Putin said. “Faced with one of the hardest situations, she took responsibility for making these important decisions.”

Ms. Tymoshenko said, “I am very much obliged to Vladimir Vladimirovich and his team for finding the opportunity to grant special terms for Ukraine.”

The contracts will be valid for 10 years but adjusted to current market prices.

The contract provides that the price of Russian natural gas in Ukraine will be pegged to prices in Europe, which are linked to international oil prices, but with a 20 percent discount in 2009. The discount will be eliminated next year.

Under that formula, Ukraine could be expected to pay $208 to $240 for 1,000 cubic meters of natural gas. It paid $179.50 last year.

Russia had initially asked for $250 but raised that to $450 in the midst of the shutoff.

Ukraine, meanwhile, accepted a transit fee that is about half the average rate in Europe, but with the understanding that it will be raised next year.

Russia halted shipments of gas to Ukraine on Jan. 1 and then, accusing Ukraine of siphoning gas intended for export, halted shipments intended for export on Jan. 6.

http://www.nytimes.com/2009/01/20/world/europe/20russia.html?ref=todayspaper&pagewanted=print

Copyright 2009 The New York Times Company