Moldova has voted in favor of opening a path to European Union membership in the coming years by a slim margin as the former Soviet republic seeks to break the Kremlin’s decadeslong grip.

Some 50.5% of Moldovans approved the measure with a margin of more than 13,000 votes, according to a preliminary tally of almost all ballots by the Central Electoral Commission in Chisinau.

The outcome — an unexpectedly tight one for the nation of 2.6 million after polls had shown a consistent majority in favor before the ballot — shows the challenge Moldovan President Maia Sandu faces in integrating the country into the West, and the divisions that remain over the legacy of ties with Russia.