KAMPALA, Uganda—Huawei Technologies Co., the world’s largest telecommunications company, dominates African markets, where it has sold security tools that governments use for digital surveillance and censorship.

But Huawei employees have provided other services, not disclosed publicly. Technicians from the Chinese powerhouse have, in at least two cases, personally helped African governments spy on their political opponents, including intercepting their encrypted communications and social media, and using cell data to track their whereabouts, according to senior security officials working directly with the Huawei employees in these countries.

In Kampala, Uganda, last year, a group of six intelligence officers struggled to contain a threat to the 33-year regime of President Yoweri Museveni, according to Ugandan senior security officials. A pop star turned political sensation, Bobi Wine, had returned from Washington with U.S. backing for his opposition movement, and Uganda’s cyber-surveillance unit had strict orders to intercept his encrypted communications, using the broad powers of a 2010 law that gives the government the ability “to secure its multidimensional interests.”

According to these officials, the team, based on the third floor of the capital’s police headquarters, spent days trying to penetrate Mr. Wine’s WhatsApp and Skype communications using spyware, but failed. Then they asked for help from the staff working in their offices from Huawei, Uganda’s top digital supplier.

“The Huawei technicians worked for two days and helped us puncture through,” said one senior officer at the surveillance unit. The Huawei engineers, identified by name in internal police documents reviewed by The Wall Street Journal, used the spyware to penetrate Mr. Wine’s WhatsApp chat group, named Firebase crew after his band. Authorities scuppered his plans to organize street rallies and arrested the politician and dozens of his supporters.