A woman exits from a voting cabin at a polling station in the Hrusova village, Criuleni district, 30 kilometers north-east of the capital Chisinau, Moldova, during parliamentary elections on 30 November 2014. Campaigning focused on whether the landlocked country wedged between Romania and Ukraine should align with Russia or the West. (Dumitru Doru/EPA)

VLADIMIR PUTIN has been adept at using military force to gain control over pieces of neighboring countries that he regards as part of the Kremlin’s rightful dominion. Democratic elections, on the other hand, vex him. On Sunday he lost another one: Moldova, a former Soviet republic wedged between Ukraine and Romania, voted to retain its pro-Western government despite a robust Russian campaign to install its own clients. The result means the nation of 3.5 million will continue on its course of integration with the European Union — provided that Mr. Putin does not again resort to armed aggression.

The electoral contest between the governing coalition of liberal democratic parties and pro-Russian opponents was close: The liberals won 44 percent of the vote, compared with 39 percent for the Putinists. That was not a surprise. In addition to facing heavy political and economic pressure from Moscow, the government had the misfortune to rule during the global economic downturn, and for much of the last year it trailed the opposition in polls.

In the end voters were offered a stark choice. Leaders of the Socialist party tied themselves directly to Putin and promised to lead Moldova into his Eurasian Economic Union, while the incumbents promised to build on an association agreement they signed in June with the European Union, which provides for free trade as well as visa-free travel for Moldovans. In September, another Kremlin stalking-horse suddenly appeared: a party called Patria, led by a shadowy Russian businessman who staged campaign rallies with popular Russian entertainers and, according to the election authority, received more than $600,000 in illicit funding.

A decision by Moldova’s high court removed the party from the ballot last week; as its founder fled to Moscow, authorities raided several Russian-sponsored nongovernmental organizations, where they confiscated weapons as well as cash. Predictably, the Kremlin’s propaganda organs cried foul. But a statement issued Monday by the official observer team of the Organisation for Security and Cooperation and Europe (which includes Russia) concluded that “a largely well-run election offered voters the opportunity to choose their preferred candidates and even geopolitical aspirations, which was at the heart of the campaign.”

The question now is whether Mr. Putin will respect the voters’ choice. Already Russia occupies a portion of Moldova known as Transnistria, where it has installed a puppet state like those in occupied portions of Ukraine and Georgia. In a transparent attempt to intimidate voters, Russian officials threatened before the election that further steps might be taken to separate Transnistria from Moldova. Russia is also promoting separatism in another region, Gagauzia, and has hinted it could cut off the gas exports on which Moldova depends for most of its energy.

Western leaders were surprised when Mr. Putin responded to Ukraine’s pro-Western revolution by launching a covert military invasion of Crimea, and surprised again when Moscow fomented an armed insurgency in eastern Ukraine. They should not be surprised if similar aggression is launched against Moldova. Its leaders and its voters have stood up against Mr. Putin’s imperialism; Western governments should be prepared to do the same.