KYIV, Ukraine (AP) — The final day of voting was taking place in Russian-held regions of Ukraine on Tuesday in referendums that are expected to serve as a pretext for their annexation by Moscow and is heightening tension between the Kremlin and the West over Russia's warnings it could resort to nuclear weapons.

Formal annexation of captured chunks of eastern Ukraine, possibly as soon as Friday, sets the stage for a dangerous new phase in the seven-month war, with Russia warning the West that from then on it will be defending its own territory — and could resort to nuclear weapons to protect it.

Faced with recent humiliating battlefield setbacks for the Kremlin's forces in Ukraine, Russian President Vladimir Putin is using the ballot to try and force Ukraine to halt its counteroffensive. If it doesn't, the Kremlin has cautioned, Kyiv faces a devastating escalation of the conflict, all the way up to the use of its nuclear arsenal.

Dmitry Medvedev, deputy head of Russia’s Security Council chaired by Putin, spelled out the threat in the bluntest terms yet Tuesday.

“Let’s imagine that Russia is forced to use the most powerful weapon against the Ukrainian regime that has committed a large-scale act of aggression, which is dangerous for the very existence of our state,” Medvedev wrote on his messaging app channel. “I believe that NATO will steer clear from direct meddling in the conflict in that case.”

Kyiv and its Western allies have dismissed the Kremlin's nuclear talk as scare tactics.

Jake Sullivan, the U.S. national security adviser, responded to Putin's nuclear threats from last week. Sullivan told NBC on Sunday that Russia would pay a high, if unspecified, price if Moscow made good on threats to use nuclear weapons in the war in Ukraine.

The Ukraine war is still gripping world attention, as it causes widespread shortages and rising prices not only for food but for energy, inflation hitting the cost of living everywhere, and growing global inequality. The talk of nuclear war has only deepened the concern.

Misery and hardship are often the legacy of Russia's occupation of Ukrainian areas now recaptured by Kyiv’s forces. Some people have had no gas, electricity, running water or internet since March.

The war has brought an energy crunch for much of Western Europe, with German officials seeing the disruption of Russian supplies as a power play by the Kremlin to pressure Europe over its support for Ukraine.

The referendum in Russian-held areas of Ukraine, whose outcome is expected to be a predetermined victory for Moscow, is rejected as a sham by Ukraine and many other countries.

The five-day voting, in which residents are asked whether they want their regions to become part of Russia, has been anything but free or fair. Tens of thousands of residents had already fled the regions amid the war, and images shared by those who remained showed armed Russian troops going door-to-door to pressure Ukrainians into voting.

The balloting on Tuesday was held at polling stations.

With his back against the wall amid Ukraine's battlefield successes, Russian media are speculating that Putin may follow up on last week's order of partial mobilization by declaring martial law and shutting the nation's borders for all men of fighting age.

The call-up has in some ways backfired on Putin. It has triggered a massive exodus of men from the country, fueled protests in many regions across Russia and sparked occasional acts of violence. On Monday, a gunman opened fire in an enlistment office in a Siberian city and gravely wounded the local chief military recruitment officer. The shooting came after scattered arson attacks on enlistment offices.

In the latest move to stem the tide of men fleeing Russia to avoid mobilization, Russian officials declared plans to set up a military recruitment office right on the border with Georgia, one of the main routes of the exodus.

And trying to assuage public outrage, numerous Russian officials and lawmakers have acknowledged that mistakes were made during the mobilization — when military conscription offices were rounding up random people without military experience who weren't supposed to be called up — and promised to quickly correct them.

Ukrainian President Volodymyr Zelenskyy on Monday once again decried the Russian mobilization as nothing more than “an attempt to provide commanders on the ground with a constant stream of cannon fodder.”

Zelenskyy vowed that the Ukrainian military will push efforts to take back “the entire territory of Ukraine,” and has drawn up plans to counter “new types of weapons” used by Russia.

Turkish Foreign Minister Mevlut Cavusoglu said Monday that Putin had told Turkey’s president last week that Moscow was ready to resume negotiations with Ukraine but had “new conditions” for a cease-fire.

Even as the voting has continued in Russia-held areas, Russian forces have kept up their strikes across Ukraine. Overnight, Russian missile attacks targeted the southern areas of Zaporizhzhia and Mykolaiv, damaging residential buildings and other sites, officials said.