After the weapons charges were dropped, however, he was quickly re-arrested by police on Thursday and now faces potentially more serious charges of treason in a civilian court.
The court ordered he be remanded in custody in the northern city of Gulu, about 330km north of Kampala, until August 30.
It was the first time the legislator had been seen in public since his detention amid allegations he had been beaten while in custody. Walking with a limp, he clenched his fists and greeted supporters.
Uganda pop star-turned-opposition leader Bobi Wine to face court
“The bogus charges have been dropped,” attorney Medard Sseggona told local broadcaster NBS. “They claim they prefer charging him with the more serious offense of treason.”
The popular musician has emerged as an influential critic of President Yoweri Museveni after winning a seat in parliament last year.
‘A lot of pain’
The lawmaker had been arrested with four other opposition lawmakers, three of whom also face treason charges. A fifth legislator was hospitalised with injures allegedly sustained during detention.
Al Jazeera’s Catherine Soi in Kampala reported Kyagulanyi looked physically unwell.
“He appears to be very weak and in a lot of pain. He has been having difficulties getting up from his chair,” she said.
Dozens of other Ugandans have been charged with treason and illegal possession of firearms over their alleged role in the stoning of the president’s convoy after a local election rally.
In recent days, Uganda’s government has faced pressure to free Kyagulanyi, with dozens of musicians around the world speaking out against his alleged beating in detention.
Security forces in recent days have violently put down street protests by Ugandans demanding his release. Scores were arrested in riots in Kampala on Monday, and video by local broadcasters showed men in military uniforms beating up people, including at least two journalists.
Ugandan police also arrested two opposition politicians on Thursday for defying police orders not to leave their homes.
Kizza Besigye, who contested and lost four elections against Museveni, and Kato Lubwama were taken to police detention facilities, police spokesman Emilian Kayima said.
Earlier, police surrounded the homes of several opposition politicians, saying they had been placed under “preventative arrest” to try to stop unrest.
In a statement late Wednesday, Museveni accused “unprincipled politicians” of luring youth into rioting.
Responding to calls on social media to #FreeBobiWine, the president said he had no power to do so. “Let us therefore wait for the courts and see what they decide.”
Museveni took power by force in 1986 and has since been elected five times. Although he has campaigned on his record of establishing peace and stability, some worry those gains are being eroded the longer he stays in power.
The 74-year-old Museveni is now able to seek re-election in 2021 because parliament passed legislation last year removing a clause in the constitution that had prevented anyone over 75 from holding the presidency.