The UN Human Rights Council has agreed to appoint an independent investigator to help protect homosexuals and transgender people worldwide from violence and discrimination.
After a heated debate lasting almost four hours, the 47-member state forum overcame strong objections by Saudi Arabia and some other countries to adopt a Western-backed resolution by a vote of 23 states in favour and 18 against with six abstentions.
The United Nations expert, still to be named, will have a three-year mandate.
Mexico, which led Latin American states that were the main sponsors of the text, said that thousands of people are exposed to violence and discrimination due to their sexual orientation and gender identity.
"Remember Orlando," Mexican Ambassador Jorge Lomnaco told delegates, referring to the massacre of 49 people at a gay club in Florida on June 12. "Let us give hope to millions."
The United States and major European countries backed the resolution, while China, Russia and 16 African and predominantly Muslim states rejected it.
India, South Africa and the Philippines were among the abstainers.
"This Council regularly - and rightly - passes resolutions on racism, women and children.
"Yet, on this issue, we often hear of culture and tradition as reasons to justify violence against individuals based on their sexual orientation and gender identity," British Ambassador Julian Braithwaite said in debate.
"This affects people in this room, and people in my team who are LGBT. Are you saying it is okay to discriminate against them based on their sexual orientation and gender identity? To hit, torture, or possibly kill them?"
Early in the session, Saudi Ambassador Faisal Trad brought a "no-action motion" to quash any debate on the resolution, but his move was defeated.
Trad argued against what he called "the imposition of certain ideas" and said the new post would open up a "Pandora's box" while ignoring cultural and religious specificities.