South African President Jacob Zuma has lost two court cases in one day, both linked to corruption allegations.
Pretoria's High Court ordered Zuma to set up a judicial inquiry, calling him "seriously reckless" for challenging recommendations by a watchdog in a case against him.
In the second case, a judge ruled he had abused the judicial process by trying to block a report on corruption, ordering him to pay legal fees.
Zuma quits as ANC leader next week.
The party is currently battling to choose Zuma's successor as leader. He is due to remain as president until elections in 2019.
In his 10-year term he has been dogged by allegations of corruption, all of which he denies.
BBC Africa correspondent Andrew Harding says the South African judiciary is flexing its muscles, at a time of deepening anxiety about state corruption and apparent impunity.
In the first ruling, the court gave Zuma 30 days to appoint an inquiry into allegations of corruption against him and his associates.
The inquiry was one of the recommendations on state influence-peddling by the country's anti-corruption watchdog, which the president had tried to challenge.
Judge President Dunstan Mlambo described Zuma's attempt to challenge the rulings as "ill-advised" and an abuse of the judicial process.
As yet Zuma has not commented on the decision.
Withering and unprecedented
In a separate case, Judge Mlambo also ruled that Zuma had been unreasonable in trying to use the courts to block the publication of an explosive official report into high-level corruption, known as state capture.
He ordered Zuma to pay all legal costs out of his own pocket.
Our correspondent describes this as a withering and unprecedented judgement against a sitting president.
The report's author, Thuli Madonsela, told Reuters after the verdict: "An allegation that the state has been captured in the interests of the president and his friends is an allegation that needs to be investigated immediately."
Zuma has been accused of conspiring with a wealthy business family, the Guptas, to control lucrative state contracts.
He has also faced allegations that his close links to the family have been used to influence the appointment of key ministers.
The Guptas deny any wrongdoing.
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 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