President Obama on Wednesday used a speech in Estonia to deliver a stern warning to Vladimir Putin's Russia, saying the NATO alliance would not accept Russian annexation of "any part of Ukraine" and that "borders cannot be redrawn at the barrel of a gun."

The president's stop in the small Baltic nation en route to a NATO summit in Wales was designed to send a message to Putin, and he devoted the bulk of his 30-minute address to condemning Russia's aggression in Ukraine and vowing a unified response.

"We will stand firm and united to meet the test of this moment," Obama said.

The speech at the Nordea Art Concert Hall came hours after Ukraine retracted a statement claiming its president had struck a ceasefire agreement with Putin.

Obama called Russia's armed support for the separatists in eastern Ukraine a "brazen assault" on the nation's territorial integrity.

"We will not accept Russia’s occupation and illegal annexation of Crimea—or any part of Ukraine," Obama said.

He also used the speech to reassure Estonia and other Baltic nations that NATO would defend their sovereignty just as it would the larger, more powerful members of the alliance.

"We will defend the territorial integrity of every single NATO ally," Obama said. Paying homage to Estonia's frequent battles for independence in its history, he said, "You lost your independence once before. With NATO, you will never lose it again."

The president's speech was also aimed at bucking up the North Atlantic alliance ahead of its meeting. Obama touted his proposals to position more U.S. equipment and ground forces in Europe for the defense of the Baltic states, and he prodded all NATO members to pay up to ensure regional security.

This is a moment of testing.

The actions of the separatists in Ukraine and Russia evoke dark tactics from Europe’s past that ought to be consigned to history."

As he has before, Obama argued that the sanctions imposed against Russia had hurt the country and that Putin still had a chance to choose a different path.

"That path remains available to Russia," he said. "But it’s a path that starts with Russia changing course and leaving Ukraine."

Obama concluded his speech by returning to the themes of many of his foreign addresses, arguing that nations supporting justice, freedom and democracy will ultimately triumph over those that "bully."

"The currents of history ebb and flow, but over time they flow toward freedom," Obama said.