BUCHAREST — A referendum to change Romania’s constitution to prevent same-sex couples from securing the right to marry failed to draw enough voters to validate the result on Sunday, after a campaign that led to a rise in hate speech against the gay community.

The vote has also been seen as popularity test of the ruling Social Democrat Party (PSD) that supported the change and whose attempts to weaken anti-corruption legislation have drawn criticism from the European Union’s executive.

Data from the national election bureau showed voter turnout stood at 20.4 percent when the polls closed , below the 30 percent required for it to be valid.

"Romanians rejected being divided and hating each other, it is a victory for Romanian democracy and moreover, Romanians rejected the involvement of the Orthodox Church in the state’s secular affairs."

The two-day referendum, which cost $40 million, aimed to change the constitution to define marriage as strictly between a man and a woman from the current gender-neutral “spouses.”

Religiously conservative Romania, which decriminalized homosexuality in 2001 decades after neighboring countries, bars marriage and civil partnerships for same-sex couples.

Civil society group Coalition for the Family secured 3 million signatures to trigger the vote aimed at preventing gay couples winning the right to marry in the future.

The Coalition received backing from the Orthodox Church and other religions as well as all but one parliamentary parties.

“Romanians rejected being divided and hating each other, it is a victory for Romanian democracy and moreover, Romanians rejected the involvement of the Orthodox Church in the state’s secular affairs,” said Vlad Viski of LGBTQ-rights group MozaiQ.

“We believe politicians must now legalize civil partnerships for same sex couples,” he said at a party to celebrate the outcome.

Dozens of human-rights groups had said a successful referendum would embolden further attempts to chip away at the rights of minority groups and push Romania onto a populist, authoritarian track.

They have encouraged people to boycott the ballot, with several companies and popular musicians and artists following. A library chain even offered a book discount over the weekend for those who wanted to stay in and read rather than vote.

In villages across the country, people were quoted saying they had better things to do, such as canning food and making wine.

“The PSD staked everything on the referendum, by associating with it and trying to capitalize on it,” said Sergiu Miscoiu, a political science professor at Babes-Bolyai University.

“What remains is the fact that many citizens have associated the initiative with the PSD and that is why they boycotted it. Either way, it is a major sanction against the government.”

Senior PSD member Codrin Stefanescu accused opposition parties and centrist President Klaus Iohannis of misinforming Romanians in the run-up to the vote.

PSD leader Liviu Dragnea, whose appeal against a criminal conviction in an abuse of office case starts on Monday, told reporters after voting “Yes” to the change on Saturday that Romanians had to decide the kind of country they wanted.

“We all know that for years we’ve been told others know what is best for us better than we do. I believe it is time we decide what kind of society and country we want to have and how we want to live in our country,” Dragnea said.

Days before the vote, the government relaxed anti-fraud monitoring and limited options for challenging the result.

Romania ranks 25th out of 28 EU states based on legislation, hate speech and discrimination against LGBTQ people, an annual study by ILGA-Europe, an umbrella organization advocating for equality, showed.

FOLLOW NBC OUT ON TWITTER, FACEBOOK AND INSTAGRAM