The overthrown Egyptian president was released after the court found he could no longer legally be held before having a retrial.