A Ugandan court has ordered the military and police to leave the home of opposition politician Bobi Wine.
He has not left his house in the outskirts of the capital Kampala since voting in the presidential election 11 days ago, in which he was declared runner-up to President Yoweri Museveni.
Monday’s ruling by the High Court in Kampala comes after a petition by Bobi Wine’s lawyers.
The state argued it needed to prevent him organising protests.
But the High Court has now ruled that Bobi Wine’s detention was unlawful, with Justice Micheal Elubu telling the court it was also an “an infringement on his personal liberties”.
Dozens of people were killed during campaigning – many were shot by security forces.
Bobi Wine alleges that the election, in which he won 35% of the vote as National Unity Platform leader, was rigged.
Uganda’s Electoral Commission said the vote was peaceful, but the EU, United Nations and several rights groups have raised concerns. Aside from an African Union mission, no major international group monitored the vote.
Armed police and soldiers have been stationed outside the musician-turned-politician’s residence, not allowing anyone in or out.
Several more have been patrolling the neighbourhood.
Army spokesperson Brigadier Flavia Byekwaso has told the BBC that the security agencies will respect the court order.