Last week, there were reports in the Swedish and Finnish press about what was presumed to be a Russia submarine probing the harbors in both Stockholm and Helsinki. This was not viewed as a serious Russian threat but merely an extension of the general and low-level harassment the Russians have displayed against their European neighbors, particularly the Baltic nations.

The European Union is not the first free-trade and defense bloc to arise in Europe. Six hundred years ago, the Hanseatic League held both economic and military sway in an area that at its farthest extent went from Novgorod in northern Russia to trade zones near London. The league was centered in the German city of Lubeck on the Baltic. Members of the league included towns and cities in modern-day Germany, Denmark, Poland, Lithuania, Russia, Finland, Sweden, the Netherlands and Belgium. The Hanseatic League established free trade among its members, who agreed to a basic charter. It also established its own navy and defense force to protect its cargos, and it succeeded in largely eliminating pirates from the Baltic.

The first trade alliances that evolved into the league began after the end of the Viking era in the 12th century and lasted until the rise of the Swedish Empire, which gained control over most of the Baltic Sea in the 16th century. Many of the members of the league were “free cities and towns,” and others were controlled by local princes. It was the merchant class that was the driving force behind the league in that the rise in trade became highly profitable to them and greatly increased the prosperity of those living in the league trading area. Over the centuries, cities dropped in and out of membership as circumstances changed.

The EU faces many of the same types of pressures that the league faced. Not all members of the league abided by the rules all of the time — read Greece — but the league endured. Some members were harassed or even attacked by neighboring kingdoms — read Russia — but the league endured for more than three centuries.

Vladimir Putin’s Russia has been engaged in a low-level campaign to harass and intimidate some of its neighbors for very understandable political and economic reasons. Mr. Putin has been clear in his goal to recreate the Russian Empire as his legacy, thus he claims the right to protect Russians, even when they live outside of Russia. More than a quarter of the population of Estonia is Russian. The Estonians are bombarded with Russian propaganda through the Russian RTV and other sources. The Russians provide financial benefits to politicians, journalists and others who take a pro-Putin-Russian line — not only in Estonia, but elsewhere.

The NATO countries had agreed to spend 2 percent of their gross domestic product on defense, yet most of them are falling short of this self-proclaimed goal. (Note: 2 percent may be too little or too much or even a poor measure of what is needed for the common defense.) The desire of politicians to spend money on things other than defense as well as Russian influence are likely to explain much of this shortfall. However, now the fear of Russia is rising in the Baltic states as a reaction to both Russia’s actions in Ukraine and statements from its leaders. This growing fear is fueling demands for increased defense spending in the countries on Russia’s borders.

Most of the individual European countries, particularly the very small Baltic countries, do not have the military resources to provide a credible defense against Russia — hence the need for a military alliance, i.e., NATO. Even though they are members of NATO, can they be secure that NATO will come to their defense? And does Mr. Putin think NATO will come to their defense?

The fact is the more these countries spend on their own defense, the less they will be perceived as NATO free riders, and the more difficult it will be for President Obama and the other leaders of the NATO countries to find excuses not to defend them. The Estonians were able to fend off a major Russia cyberattack in 2007. This may have been a Russian test for what could be a much bigger and more widespread cyberattack on the EU and even the United States in the future.

U.S. and European critics of Russian policies, including government officials and foreign nationals living in the United States, have experienced cyber-attacks, low levels of harassment, and disinformation leveled against them — the source of which is very difficult to prove with certainty. Yet there is considerable evidence of Russian aid to U.S. environmental groups to assist them in their opposition to oil and gas drilling and fracking — because it is in Russia’s interest to curtail the growth of non-Russian suppliers.

The Hanseatic League prospered for more than three centuries from both its willingness to remove members who failed to play by the rules and to vigorously defend members against those who sought to harm them. The EU and NATO need to do the same.