South Africa's top court has found that parliament failed to comply with its duties in holding President Jacob Zuma accountable over a public funding case.
The ruling said parliament must now set out rules for impeachment proceedings, but it remains unclear whether this will lead to any impeachment.
The court was hearing a case brought by opposition groups who wanted parliament to be compelled to begin impeachment.
It relates to Mr Zuma's use of state funds to upgrade his private home.
Handing down the Constitutional Court ruling, Judge Chris Jafta said: "We conclude that the assembly did not hold the president to account.
"The assembly must put in place a mechanism that could be used for the removal of the president from office."
But the court said it could not intervene on how parliament determined the mechanism and that it had no power to order an impeachment
The court awarded costs against Mr Zuma and parliament.
The court ruling was by majority. Dissenting Chief Justice Mogoeng Mogoeng said the ruling was a clear case of "judicial overreach".
Some $15m (£11.1m) in state money was spent upgrading Mr Zuma's home.
In March 2016, the court ruled he had ignored a watchdog's findings and said he must pay some of the money back. The president has reimbursed $631,000, deemed by the Treasury to be "reasonable".
Parliament then debated the matter and he survived a no-confidence vote, but Friday's court ruling said that the procedures it followed were insufficient.
Mr Zuma has been weakened by a number of corruption allegations and by his recent replacement by Cyril Ramaphosa as head of the ruling ANC.
Mr Zuma, 75, is scheduled to remain president until general elections in 2019.
He has faced a number of corruption allegations, all of which he denies.
Earlier this month Mr Zuma lost two court cases in one day, both linked to corruption allegations.
Zuma's legal woes:
- 2005: Charged with corruption over multi-billion dollar 1999 arms deal - charges dropped shortly before he becomes president in 2009
- 2016: Court orders he should be charged with corruption over the deal - he has appealed
- 2005: Charged with raping family friend - acquitted in 2006
- 2016: Court rules he breached his oath of office by using government money to upgrade private home in Nkandla - he has repaid some of the money
- 2017: Public protector said he should appoint judge-led inquiry into allegations he profiteered from relationship with wealthy Gupta family - he denies allegations, as have the Guptas