Estonia's Parliament has narrowly passed legislation to legalize gay partnerships, making it the first former Soviet republic to do so.

In a 40-38 vote, lawmakers voted Thursday in favor of a civil partnership act that recognizes the civil unions of all couples regardless of gender. Twenty-three lawmakers were absent or abstained in the third and final reading of the bill.

The new law comes into force in 2016.

Estonia, which like Baltic neighbors Latvia and Lithuania was occupied by the Soviet Union for almost five decades, is deemed the most Western-oriented of the former republics ruled by Moscow.

The Estonian Human Rights Center hailed the law as "historic," saying it would send a strong message to neighboring Russia, which passed what it called "a draconian anti-gay law" last year.