Ugandan rights activists say grisly images of the torture of a detained politician showing septic wounds on his body highlight escalating brutality and impunity by the country's security personnel.

Pictures began circulating online and in local media on Thursday of Geoffrey Byamukama, mayor of a small town in western Uganda, lying on a hospital bed with gaping wounds on his swollen knees and ankles, and bruises elsewhere on his body.

Eric Rugira - a friend of Byamukama who visited him in the hospital where he is being treated and held - said Byamukama had told him the wounds came from "hours of torture" at the hands of police shortly after his arrest.

"He is in a terrible shape," Rugira said.

The images of Byamukama have elicited widespread anger and denunciation from Ugandans on social media. He was arrested on April 5 on suspicion that he had participated in the murder of a senior police official, Andrew Felix Kaweesi, on March 17.

READ MORE: Museveni critic 'resists forced psychiatric exam'

Security services deny accusations of using torture to wring confessions from suspects.

President Yoweri Museveni, 72, has often expressed support for his top police boss, whom he has praised for helping to contain protests against his government.

Police spokesman Asan Kasingye said two security personnel had been arrested in connection with Byamukama's torture but gave no further details.

"We do not condone torture ... it is not our method of work," he told Reuters news agency.

Sarah Birete, programme director at the Centre for Constitutional Governance, disagreed.

"Torture to get information from suspects is the standard now and we are yet to see more. This is typical in an illegitimate regime where impunity reigns," she said, adding that police have also been accused of kidnappings and robberies.

WATCH: Uganda - Living In Fear

A total of 22 suspects have so far been charged in connection with Kaweesi's murder, although Byamukama was not among those charged. Some have appeared in court shirt-less, their bodies also showing what appeared to be torture marks.

Some government critics have pointed to rivalry among various top security officials and said the murder was possibly an assassination by Kaweesi's enemies within the police.

Museveni, in power since 1986, won re-election last year in a disputed poll that several international observers said lacked credibility and transparency.

"We appear to be going back to the dark days ... when extrajudicial measures were being used to resolve crime," said Nicholas Opiyo, a rights lawyer and activist.