Image copyright Getty Images Image caption Human rights groups have been lobbying for an UN investigation into the war on drugs

The UN Human Rights Council has voted to set up an investigation into alleged crimes committed during the Philippine government's war on drugs.

The resolution, which passed by a narrow margin, mandates a comprehensive written report into the human rights situation in the country.

It will focus on reports of extrajudicial killings, arbitrary arrests and enforced disappearances.

The Philippines strongly opposed the resolution and branded it a "travesty".

President Rodrigo Duterte launched the anti-narcotics campaign in 2016, to deal with a rampant drug problem.

Since then at least 6,600 dealers or users have been killed, according to police, but activists say more than 27,000 people have died.

Last week, a three-year-old girl became one of the crackdown's youngest victims after she was shot dead in a drugs raid. Police said she had been used as a human shield by her father, but the family disputes this.

Mr Duterte and his anti-narcotics campaign enjoy wide support from Filipinos. An opinion poll earlier this year gave him a 79% approval rating.

The latest UN resolution secured the backing of 18 states in the 47-member council, while 14 nations opposed it and 15 countries abstained.

"We have put forward a balanced text with a very modest ask - simply requesting the High Commissioner to prepare a report for discussion by June next year," the ambassador for Iceland, which sponsored the resolution, said on Thursday.

Media playback is unsupported on your device Media caption Duterte drug war: Manila's brutal nightshift

The Philippines' ambassador to the UN hit back at the resolution shortly after the vote.

"We will not accept a politically partisan and one-sided resolution," he said, reading a statement on behalf of the country's Secretary of Foreign Affairs Teddy Locsin Jr.

"This resolution does not represent a triumph of human rights but a travesty of them," he added. "There will be consequences."

The council stopped short of setting up a full commission of inquiry, but their pledge to produce a detailed report has been welcomed by human rights groups.

"This vote provides hope for thousands of bereaved families in the Philippines," Amnesty International said in a statement. "It's a crucial step towards justice and accountability."

The deputy Geneva director for Human Rights Watch, Leila Matar, said it was a "modest but vital" step.