Russia has said it may target its missiles at Ukraine if its neighbour joins Nato and accepts the deployment of the US missile defence shield.
Russia has warned that a new arms race is unfolding around the world
Russian President Vladimir Putin made the comments in Moscow alongside Ukraine's President, Viktor Yushchenko.
Mr Putin has condemned US plans to include Poland and the Czech Republic in its missile defence shield.
The leaders had been meeting in urgent talks over a gas dispute and announced a deal to avoid disrupting supplies.
Speaking at a news conference at the Kremlin on Tuesday, Mr Putin said he had advised Ukraine not to join Nato, but admitted he would be unable to interfere in any such move.
"Restrictions on sovereignty... have already had certain consequences, such as the stationing of bases or a positioning area for missile defence in Eastern Europe, which we believe is aimed at neutralising our nuclear missile potential," he said.
"Russia therefore faces a need to take retaliatory action."
The US wants the shield to destroy incoming ballistic missiles potentially coming from North Korea and Iran.
Current plans would see some interceptor missiles based in Poland and an associated radar built in the Czech Republic.
"It is frightening not only to say but even to think that Russia, in response to the emergence of such positioning areas on Ukrainian territory, which cannot be ruled out in theory, will target its offensive missile systems at Ukraine," he said.
"Can you imagine that for a second? That is what we are concerned about."
President Yushchenko said he realised a number of "sensitive issues" would emerge from Ukraine's attempt to join Nato, but that he hoped they could be dealt with through dialogue, openness and trust.
"One must realise that everything Ukraine is doing in this area is certainly not aimed against any third country, especially Russia," he added.
In a televised speech to the Russian State Council last week, Mr Putin had warned that a "new phase in the arms race is unfolding in the world".
He said other countries were spending far more than Russia on new weapons, but that his country would respond to the challenges of an arms race by developing hi-tech weaponry.
On the gas dispute, Ukraine agreed to start repaying $1.5bn (£770m) owed to the Russian gas company, Gazprom, from Thursday. In return, Russia is reported to have agreed to freeze the price of gas exports to Ukraine at last year's level.
The dispute had raised concerns in European countries, which experienced disruption to their gas supplies as the result of a similar dispute two years ago.
Separately on Tuesday, Russian Foreign Minister Sergei Lavrov said Mr Putin had accepted an invitation to attend the forthcoming Nato summit in the Romanian capital, Bucharest, in April.
Mr Putin will no longer be Russian president in April. Elections for his successor will be held next month.
"This yet again testifies to the fact that Russia is open to dialogue on any issues," Mr Lavrov told reporters while attending the Conference on Disarmament in Geneva.
At the conference, Russia and China proposed a new treaty to ban the use of weapons in space and the use or threat of force against satellites or other craft.