Ugandan activist Stella Nyanzi has been set free by the High Court on appeal.
But then she reportedly collapsed immediately after the ruling before signing her release papers, forcing prison authorities to detain her.
Nyanzi was in August 2019 convicted and sentenced to 18 months in prison after she was found her guilty of harassing President Yoweri Museveni.
The charges related to social media posts on her Facebook page touching on the First family.
She appealed the conviction and sentence, citing unfairness and that the trial erred in law.
On Thursday, Justice Henry Peter Adonyo of the High Court ordered her immediate release from prison after noting that Buganda Road trial magistrate Gladys Kamasanyu had no jurisdiction to convict Nyanzi of cyber harassment.
The judge also noted there was no evidence adduced by prosecution showing the location of the device where the offence was committed.
During her stay at the Luzira Prison, Nyanzi wrote a book detailing her experiences.
She also won the Oxfam Novib/PEN International Award for Freedom Expression.