In this March 9, 2023 photo, Democratic Republic of Congo Defence Forces gather in the North Kivu province village of Mukondi after the Allied Democratic Forces, a group with links to the Islamic State group, attacked the village and burned residents' huts, killing at least 36 people. (PHOTO / AP)

Militants linked to Islamic State killed 25 people in a terrorist attack on a school in western Uganda near the border with the Democratic Republic of Congo, Ugandan police said on Saturday.

Members of the Allied Democratic Forces (ADF), a Ugandan group based in eastern Congo that has pledged allegiance to Islamic State, attacked Lhubirira secondary school in Mpondwe, burning a dormitory and looting food late on Friday, police said.

READ MORE: Suspected Islamists kill 16 in eastern Congo attack

"So far 25 bodies have been recovered from the school and transferred to Bwera Hospital. Also recovered are eight victims, who remain in critical condition at Bwera Hospital," Ugandan police said on Twitter.

Police did not say how many of the dead were schoolchildren.

Soldiers were pursuing the attackers who fled towards Virunga National Park in the Democratic Republic of Congo, police added.

ALSO READ: At least 17 villagers hacked to death in eastern Congo

In April, the ADF attacked a village in eastern Democratic Republic of Congo, killing at least 20 people.

Uganda has sent troops to Congo to help fight the ADF.