The Philippine supreme court on Tuesday ordered the release of police documents on the killing of thousands of suspects during the president’s drug crackdown, in a ruling that could shed light on allegations of extrajudicial punishment.

Supreme court spokesman Brian Keith Hosaka said the court ordered the solicitor general to hand the police reports to two rights groups which had sought them. The 15-member court, whose justices are meeting in northern Baguio city, has yet to rule on a separate petition to declare President Rodrigo Duterte’s anti-drug campaign unconstitutional.

More than 5,000 people have died, mostly at the hands of police, between July 2016 and the end of November 2017, according to official figures released by thePhilippine drug enforcement agency (PDEA). The official toll falls well short of estimates given by human rights groups and campaigners for victims, which vary from 12,000 to 20,000. Many of the undocumented killings, rights groups say, were carried out by “death squads” and unofficial militias.

Solicitor general Jose Calida had earlier agreed to release the voluminous police documents to the court but rejected the requests of the two groups, the Free Legal Assistance Group and the Center for International Law, arguing that such a move would undermine law enforcement and national security.

The two groups welcomed the court order. “It’s a big step forward for transparency and accountability,” said Jose Manuel “Chel” Diokno, who heads the Free Legal Assistance Group.

He said the documents will help the group of human rights lawyers scrutinise the police-led crackdown that was launched when Duterte came to office in mid-2016, and the massive number of killings that the president and police say occurred when suspects fought back and endangered law enforcers, Diokno said.

Joel Butuyan, president of the Center for International Law, said: “This is an emphatic statement by the highest court of the land that it will not allow the rule of law to be trampled upon in the war on drugs. It is a very important decision."

Rodrigo Duterte launched the crackdown in 2016. Photograph: Bullit Marquez/AP

“These documents are the first step toward the long road to justice for the petitioners and for thousands of victims of the ‘war on drugs’ and their families,” he said.

More than 5,000 mostly poor drug suspects have died in purported gun battles with the police, alarming western governments, UN rights experts and human rights watchdogs. Duterte has denied ordering illegal killings, although he has publicly threatened drug suspects with death.

The thousands of killings have sparked the submission of two complaints of mass murder to the international criminal court. Duterte has withdrawn the Philippines from the court.

After holding public deliberations on the two groups’ petitions in 2017, the supreme court ordered the solicitor general to submit documents on the anti-drug campaign, including the list of people killed in police drug raids from 1 July, 2016, to 30 November, 2017, and documents on many other suspected drug-linked deaths in the same period which were being investigated by police.

Associated Press contributed to this report