Museveni and Bobi Wine
The Ugandan court gave the order after security forces surrounded Bobi Wine's home and kept him under house arrest since the mid-month presidential election.
Troops have blocked the 38-year-old pop star-turned-politician from leaving his house in a suburb of the capital, Kampala, since he voted in the January 14 election where he ran against
"The judge ordered that the state and its agencies should immediately vacate his property and his right to personal liberty should immediately be reinstated," lawyer George Musisi told Reuters.
Museveni, 76, who has been in power since 1986, was declared winner of the poll with 59% of votes versus 35% for Wine, who had for years denounced corruption and nepotism in his songs. He rejected the results, alleging fraud which the government denies.
Musisi said the judge also ruled that if there were any serious allegations against Wine, he should be brought before a court or police.
Police spokesman, Patrick Onyango, said he had no immediate comment as the ruling had not been received.
There was no immediate reaction from the government or confirmation from the court.
US ambassador, Natalie E. Brown, had tried to visit Wine at his home, drawing an accusation of meddling and subversion from the Ugandan government.