The International War Crimes Division of the High Court in Kololo, Kampala has ordered for the release of Dr Stella Nyanzi from Luzira Prison where she has been for months.
Dr Nyanzi was last year convicted and sentenced to 18 months for harassing President Museveni.
However, she appealed against the conviction and sentence citing unfairness and that the trial court erred in law.
On Thursday, Justice Henry Peter Adonyo who heard her appeal ordered for her "immediate release" from prison.
The judge noted that Buganda Road trial magistrate, Gladys Kamasanyu had no jurisdiction to convict Dr Nyanzi of cyber harassment.
In addition, Justice Adonyo said no evidence was adduced by prosecution showing the location- of the device- where the offence was committed; either Uganda or out of the country.
"Prosecution did not as well ascertain the kind of device which was used to send as the digital prints were not presented before Buganda road," the judge observed.
Court also observed that Dr Nyanzi and her lawyers were not allowed enough time to prepare their defence thus amounting to unfairness.
The first prosecution witness did not provide a forensic report on his findings indicating which mobile data was used after he asserted that Dr Nyanzi might have used a phone.
The judge also said that in criminal offences, it is the duty of court to ensure that defense witnesses appear by providing the defendant the favorable avenues like issuing arrest warrants for defence witnesses who are not compliant which the magistrate never did.
The judge's orders forced the fully packed court to explode in excitement as Dr Nyanzi's supporters, friends and relatives jostled to congratulate her.
Dr Nyanzi was in August 2019 been given an 18-month sentence but had already served nine months in Luzira Women's Prison after publishing the verse that magistrate Gladys Kamasanyu said should never have been put in the public domain, describing it as "obscene" and "indecent" including suggestions which "could only be made by an immoral person."