The outspoken university lecturer was initially arrested a month ago for posting critical comments about the president's wife.
Outspoken university lecturer Stella Nyanzi, 42, who had been detained for more than a month, collapsed as she entered the court in Kampala for the hearing.
Nyanzi was initially arrested a month ago for posting critical comments about the president's wife Janet Museveni, who is also education minister, after the government reneged on plans to supply free sanitary pads to poor schoolgirls.
She was subsequently charged with cyber harassment for calling Museveni "a pair of buttocks" on social media.
Chief magistrate James Mwanda granted Nyanzi bail until May 25 when she is due to reappear in court to respond to prosecution claims she is mentally unwell.
Wednesday's hearing was delayed by two hours after the collapse of Nyanzi, whose lawyers said needed medical attention after contracting malaria in jail.
A research fellow at Makerere University in Kampala, Nyanzi has drawn attention in the conservative country for using explicit language in high profile campaigns to defend the rights of women and girls.
The court denied state attorney Jonathan Muwaganya's request to order Nyanzi to refrain from making cyber attacks or derogatory statements against the president or members of his household as a condition of Nyanzi's release.
Defence lawyer Nicholas Opiyo said Nyanzi's legal team feared she would be re-arrested by plain-clothed security agents after she left court.
"We pray that they do not make an attempt to re-arrest her. That would be ill-advised and cast the criminal justice system in a bad light," he said.
Outside the court, police arrested four protesting university students who were calling for Nyanzi's release.
Last week, US ambassador Deborah Malac mentioned Nyanzi's case in a speech on World Press Freedom Day.
"Dr Nyanzi's case shows that... constitutional rights and freedoms apparently have limits, particularly when those opinions are critical of the country’s leaders," she said.
Ugandan government spokesman Ofwono Opondo condemned the ambassador’s comments and compared Nyanzi's case to the treatment of Edward Snowden and Julian Assange by US authorities.
"Though Uganda continues to uphold freedom of expression as guaranteed by our constitution, the government shall apprehend and prosecute those involved in suspected criminal transgressions in all its forms," he Opondo.