(Reuters) - Gunmen killed 17 people when they attacked three police stations and a military barracks in western Uganda, in an area that was once the scene of an insurgency by Islamist rebels, the military said on Sunday.

Paddy Ankunda, spokesman for the Uganda People's Defence Forces, said the dead included three policemen and five soldiers. A total of 41 of the attackers were killed while another 12 were captured during the raids on Saturday evening, he added.

The gunmen, from a local militia, had no connection to the Islamist rebel group ADF-NALU, which preyed on the local population in the late 1990s and early 2000s before it was defeated and forced to flee into the jungles of neighbouring Democratic Republic of Congo.

"What we know is that this militia is not linked with ADF-NALU but we're studying them to establish their motives and their backers," Ankunda said.

"We are interrogating those that we captured and we hope to find out who is behind these attacks."

The attackers stole 13 guns from the police stations they raided, the military spokesman added.

Uganda worries that ADF-NALU, if left unchallenged in Congo's loosely governed east, poses a threat to its oil fields in the Albertine rift basin where Tullow Oil, Total and China's CNOOC. are preparing for commercial production.