Russia could redirect its missiles towards Ukraine if the country joined Nato, Vladimir Putin warned today.
The president said he would be forced to target Russian rockets at Ukraine in response to a possible deployment of a US missile shield in the eastern European country.
"I am not only terrified to utter this, it is scary even to think that Russia … would have to target its offensive rocket systems at Ukraine," he said.
If Kiev agrees to sign up to Nato, it could host US anti-missile defences on Ukrainian soil.
The mood proved more amicable between the two neighbours moments earlier when an agreement had been reached to end the gas dispute.
Putin said Russia and Ukraine had negotiated a deal on Kiev's gas debt repayment.
The Russian state energy firm Gazprom had threatened to halt gas supplies to Ukraine today from 6pm (3pm GMT) if an agreement could not be reached, but a last-minute deal was reached.
"We have heard that the settlement of the debt will begin in the nearest time," said Putin, after talks with the Ukrainian president, Viktor Yushchenko.
Yushchenko said Ukraine would start repaying the debt, "which was amassed in November-December of last year because supply contracts had not been signed".
The debt for gas from Russia and central Asia is put at $1.5bn (£770m).
The row raised the spectre of disrupted gas supplies to Europe. A pricing dispute between Moscow and Kiev stopped shipments to EU states in 2006.
Gazprom insisted the row would not have affected gas deliveries to the EU, and would only halt Ukraine's Russian gas, which makes up 25% of Kiev's supply. Shipments would have continued from central Asia, which accounts for the remaining 75%.
In another source of tension with the west, Russia warned that a unilateral declaration of independence by Serbia's Kosovo province would violate international law and damage security in Europe.
The Russian foreign minister, Sergei Lavrov, said the US and European countries did not understand the potential consequences of independence for Kosovo, whose Albanian leaders are expected to announce the move on Sunday.
"It would undermine the basics of security in Europe, it would undermine the basics of the UN charter," Lavrov said in Geneva. He said western countries were dealing with the problem in a "haphazard" way.
"Many of them, frankly, do not understand the risks and dangers and threats associated with a unilateral declaration of Kosovo independence," he said.
"They do not understand that it would inevitably result in a chain reaction in many parts of the world, including Europe and elsewhere."
Russia has warned that Republika Serbska could call a referendum on its secession from Bosnia-Herzegovina or that the Albanian minority in Macedonia may seek independence.