A High Court in Uganda has ordered officers from Uganda police and army to immediately leave the compound of musician and presidential candidate Bobi Wine, real name Robert Kyagulanyi.

In a ruling issued on Monday, the court termed illegal and unconstitutional the continued detention of Wine in his own house in Magere.

The popstar-cum-politician has been detained in his palatial home following the disputed presidential election that saw President Yoweri Museveni retain power for a sixth term.

The opposition MP has been holed up in his home since he voted on January 14 with a battery of army and police officers surrounding his compound barring him from leaving his house.

Visitors have also been barred from accessing Wine, which has seen a planned visit by US Ambassador to Uganda Natalie Brown cancelled after she was blocked by security officials.

Security officers outside Wine's home. PHOTO/TWITTER

"We expect her to write to the Ministry of Foreign Affairs and to adhere to diplomatic norms. We don't think that a friendly country or someone who wants to help out in a difficult situation would act in this way," Government spokesman Ofwono Opondo told AFP after the incident.

Wine of National Unity Platform (NUP) posed the strongest challenge to Museveni’s hold on power after getting 3.48 million votes (34.83%) against Museveni’s 5.85 million votes (58.64%).

The Electoral Commission (EC) is being criticized for failing to publish results more than a week after declaring Museveni winner like in 2016 when it was two days after declaring the winner.