Serbian lawmakers managed to squeak out an EU-backed gay protections law on Thursday.

AFP reports that the law passed by a single vote. A slim majority of 127 members voted in favor to 59 against. 59 of the 250 member Parliament did not attend the vote. The Serbian Orthodox Church and social conservatives strongly opposed the measure.

The Parliament took about 4 hours to debate on the law that bans discrimination based on race, religion, sexual orientation or gender before putting it up for a vote.

The Serbian Orthodox Church led the opposition effort of mostly religious groups, arguing that the law could be misinterpreted. The church specifically objected to the inclusion of gay rights. Other groups said it ran counter to widely-held traditions in the conservative country.

The legislation is part of a number of reforms needed to gain entry into the European Union. Serbian leaders hope to become the 28th member nation by 2014.