An Egyptian court has ordered the release of a prominent rights lawyer held in solitary confinement for the past three months after he challenged in court a decision by the country's president to hand over two Red Sea islands to Saudi Arabia.

Thursday's decision to free Malek Adly — who hasn't been formally charged but remains incarcerated since his May arrest on a rolling series of administrative detention orders — could still be appealed by prosecutors.

Adly has been jailed with almost no communication with the outside world, sleeping on a bare floor in conditions that his lawyers say amount to torture.

Supporters say that he was a victim of a personal vendetta after he essentially insulted Egyptian President Abdel-Fattah el-Sissi in a televised interview.