Thousands of Ugandans took to the streets Monday to celebrate the release on bail of opposition leader Kizza Besigye.
Dr. Besigye walked out of a Kampala courthouse Monday after a Ugandan High Court judge, John Bosco Katutsi, ruled his detention by the military was illegal.
Police fired tear gas to disperse the celebrating supporters.
The military had held Dr. Besigye since November, when he returned from self-imposed exile to run in next month's elections against President Yoweri Museveni.
A military tribunal has charged Dr. Besigye with terrorism and illegal firearms possession. But the judge said the military's authority to hold him expired last month, when the High Court ordered the tribunal suspended.
Dr. Besigye still faces civilian charges of rape and treason. He has denied all the charges, which supporters say are politically motivated.