GENEVA — The United Nations’ main human rights body on Thursday adopted measures to strengthen protections for lesbian, gay, bisexual and transgender people, despite fierce resistance from Muslim and African countries.

The body, the 47-member Human Rights Council, voted to appoint an independent expert to monitor and report on violence against individuals on the basis of sexual orientation and gender identity. The initiative passed, 23 to 18, with six abstentions.

The vote came after a heated debate during which supporters invoked the victims of the Orlando, Fla., massacre and opponents denounced the measure on religious and cultural grounds.

The debate lasted nearly four hours and was peppered with procedural motions and amendments intended to scuttle the initiative or water it down.