TALLINN, ESTONIA—The walled Old City in Estonia’s capital, overlooking the Gulf of Finland, is the last intact medieval Hanseatic merchant town left in Europe—a monument to the unwillingness of this tiny country of 1.3 million to go away. Over the last eight centuries, having been overrun and occupied by one invader after another, Estonians have been masters of their own destiny for exactly four decades. Such is the fate of small countries with bigger, hungry neighbors.

Yet Estonia’s story over the past quarter-century, when the Soviet Union suddenly disappeared, has been a happy outlier. Regaining freedom after the Soviet implosion, Estonians worked hard to leave the Communist past behind and re-embrace their Western heritage with gusto. Their democracy is secure, their civil society is vibrant, and their economy bears few vestiges of the Soviet past. With an educated and English-speaking workforce—Estonians know foreigners will never learn their obscure and difficult language—the knowledge economy has thrived. Technology innovations are a staple of today’s Estonia (Skype being but one of their achievements), which is proud of its involvement in the cutting edge of e-everything.

Thanks to a national “smart” identity card, Estonians are far ahead of Americans in most things involving information technology. WiFi is everywhere and average citizens have gone paperless in their government interactions, voting and paying taxes online. The national ID card uses two-factor authentication, making it much more secure than anything online that’s merely password-protected.

One of the evangelists of Estonia’s e-revolution is Toomas Hendrik Ilves, a technology guru who happens to be the country’s president since 2006. Despite being past age 60, Mr. Ilves has an IT fan’s appreciation of how the digital revolution is reshaping his country—and the world.

A gadfly, and easily the most interesting head of state in Europe, President Ilves speaks several languages engagingly and his English is flawless, with a pronounced American lilt. This is because he is really from New Jersey. Like many Estonians, Mr. Ilves’ life story involves a meandering path to liberty reborn. A bit of the country’s recent history explains its president.

The Soviet collapse came suddenly—in Estonia it was happily bloodless, a testament to the population’s political maturity.

Estonia regained its freedom in 1918, at the end of the First World War, only to lose it again in the summer of 1940, when the Soviets occupied the country for a year, which was just long enough for the Communists to dispatch much of Estonia’s political and military leadership to Siberian Gulags, whence few returned.

The following summer the Germans arrived, Hitler having pushed his armies eastward to destroy the Soviets. Nazi occupation, too, proved temporary, and once the Eastern Front’s tide turned against the Germans the Soviet army headed back to Estonia. In the summer of 1944, the prospect of Stalin’s forces reoccupying the country, with the feared Soviet secret police in tow, compelled nearly ten percent of Estonians to flee the country in boats headed west.

Many of them made it to Sweden, across the Baltic Sea, including Mr. Ilves’ parents. He was born in Stockholm in 1953 but the family soon moved on to the United States, settling in Leonia, New Jersey, in the heart of Bergen County. There the future president came of age and the experience left a strong mark. An erudite man known for being nattily dressed—a three-piece suit with bow tie is the de facto presidential uniform—Estonia’s head of state remains very much Tommy from Jersey.

This explains not just his accent but his willingness to speak his mind, forthrightly. Mr. Ilves is passionate about the fate of his homeland. He worked for Estonia’s freedom in the 1980s, serving with Radio Free Europe, heading up its Estonian desk in the Cold War’s last years. There he watched the Soviet Union unravel, helping by letting Estonians know what was really happening, in their own language.

The Soviet collapse came suddenly—in Estonia it was happily bloodless, a testament to the population’s political maturity—and there were few Estonians with political skills left untainted by Communist ties. Thus did Mr. Ilves, among many other émigrés, return home in the early 1990s to help the country rejoin the West both politically and economically.

After serving as Estonia’s ambassador to the United States, his adopted home, he became foreign minister. His tenure as top diplomat from 1996 to 2002 laid the groundwork for Estonia’s key accomplishments in foreign affairs since the Soviet era, the country’s admission to NATO and the European Union in 2004. For Estonia, these memberships provide security by firmly linking the country with Western institutions. Belonging to NATO and the EU for Estonia is a tangible sign that the country cannot be returned to Russian rule against its will.

Then Mr. Ilves went into politics, being elected president in 2006. For a decade, he has used this position as a cheerful bully pulpit, extolling the virtues of his little country to all who will listen, while calling things as he sees them. Mr. Ilves has been particularly plain-spoken in his assessment of the strategic situation facing Estonia and its newly vulnerable neighborhood.

He explained his views last weekend, at the Lennart Meri Conference, the country’s premiere foreign affairs get-together. For a decade, the conference has drawn diplomats, scholars, and security mavens from dozens of countries to Tallinn, with Mr. Ilves always playing a significant role. It bears the name of Lennart Meri, a hero of the resistance to Communism who served as Estonia’s president from 1992 to 2001, reestablishing the country’s firm European footing.

At this year’s tenth anniversary conference, however, Estonia’s current president sounded a downbeat note, observing how much has changed in just a decade. Ten years ago, when Estonia and its Baltic neighbors were NATO “new members,” the security situation was good, Russia seemed no particular threat, while the Atlantic Alliance’s military commitments were all “out of area,” especially Afghanistan.

However, the last decade has witnessed a profound degradation in Estonia’s security. First came massive cyber-attacks on the country in the spring of 2007, which NATO intelligence agencies believe were the work of Russia. This was a wake-up call for Tallinn that the Kremlin meant business and had no intention of playing by the rules.

That view was reinforced in August 2008 by the Russian invasion of Georgia, which showed that Mr. Putin was perfectly willing to use force against its neighbors in the “post-Soviet space.” The big change nevertheless came in the spring of 2014 when Moscow annexed Crimea and began its war in Eastern Ukraine, a blatant case of aggression. For Estonia the implications were clear and frightening. Mincing no words, Mr. Ilves has called the Russian theft of Crimea “Mr. Putin’s Anschluss.”

Would NATO really go to war to save little Estonia from its rapacious neighbor with several thousand nuclear weapons?

Although Estonia is protected by NATO membership, as neither Georgia and Ukraine were, that is cold comfort considering the country’s tiny size. The huge neighbor to the east is capable of overrunning Estonia, if it chose to, as it did in 1940 and 1944. Making matters worse, the Kremlin has made its aggressive intentions alarmingly clear. Not long ago, Moscow delivered a diplomatic message to Tallinn in very undiplomatic language, announcing that Russia “is in a state of permanent war” with Estonia.

That war is real, if not yet overt. Russian propaganda, espionage, and covert action against Estonia, a toxic brew that I have termed Special War, is an everyday occurrence. Moscow uses spies and agitators to destabilize its smaller neighbor. Estonia’s Russian minority—a quarter of the country’s population—is a particular concern. Although many younger ethnic Russians assimilate, becoming fluent in Estonian and integrated into the country’s economy, this is no universal phenomenon and the number of disaffected Russians in Estonia is a security worry particularly because the Kremlin aims anti-Tallinn propaganda at them 24 hours a day.

Estonia’s eastern border region, around the city of Narva, is heavily Russian and a cause of concern to NATO. Cynics have noted that hardly any Russians in Estonia choose to move to Russia, though they easily could, yet some ethnic Russians are clearly disaffected. Fears of a Donbas-like semi-invasion, with Russian forces crossing the border to “save” ethnic Russians from “fascist” foreigners, are plausible.

However, most security experts think Mr. Putin is not that foolish, since any movement of Russian troops across the frontier of a NATO country risks a shooting war with the West. More likely is a miscalculation leading to an armed conflict that neither side really wants.

In September 2014, an Estonian intelligence officer was abducted at gunpoint by the Russian Federal Security Service, the powerful FSB, in the border region. The Estonian was standing in his own country when he was taken hostage and arrested by the FSB. This was a classic sort of Russian provocation that served to embarrass Estonia, and the hostage was dispatched back to home after a year’s incarceration that featured conviction by a Russian kangaroo court. Tallinn will not tolerate such brusque Kremlin shenanigans again, and if the FSB tries another such provocation, Estonian authorities will fight back. What happens then?

Would NATO really go to war to save little Estonia from its rapacious neighbor with several thousand nuclear weapons? There are certainly doubts in Tallinn about the sincerity and toughness of President Obama, but those are found in every eastern NATO capital these days. Neither does this November’s presidential election fill the Atlantic Alliance’s “new members,” who know the Russians well, with anything that can be called confidence.

“Trump hates NATO and wants to hang out with his pal Putin while Clinton wants to give the Kremlin another ‘reset’ even though the last one failed,” explained a senior NATO security official, expressing a common sentiment.

Estonia is doing all it can to provide for its own defense. Like almost no members of NATO, the country spends the “required” two percent of GDP on defense and the country’s armed forces, which rely on conscription to provide sufficient numbers of soldiers, are small but well trained and equipped. Russia could subdue Estonia but it would not be a walk-over like Crimea.

That said, the willingness of fellow Europeans to defend Estonia is in doubt. On the weekend, President Ilves cited W. H. Auden, terming recent years “a low, dishonest decade,” with too many NATO and EU partners averting eyes to the real and growing nature of the Russian threat. History did not end in 1991, as so many advanced thinkers wanted to believe. History is back in the form of an old foe, a growling bear from the east with conquest on his mind. That bear can be deterred but only if neighbors band together to do so convincingly.

Mr. Ilves is stepping down this autumn, after a decade that has witnessed profound changes for Estonia and for Europe. He is held in high esteem by those who cherish Western values, especially for his full-throated defense of freedom, particularly for small countries that too often are the playthings of others. Right now, Estonia is hosting big annual military exercises, sending a message to Moscow that this tiny county will not be bullied and cannot be taken without a real fight.

Will it be enough? Estonians are trying to be optimistic but they know their country’s history. Over the last three centuries they have spent all but 40 years under Russian occupation. It’s difficult to believe that such an advanced, freedom-loving, and forward-looking country could fall prey to the Kremlin yet again, but refusing to accept that possibility is a good way to encourage Russian risk-taking and aggression.

John Schindler is a security expert and former National Security Agency analyst and counterintelligence officer. A specialist in espionage and terrorism, he’s also been a Navy officer and a War College professor. He’s published four books and is on Twitter at @20committee.