South Africa’s highest court has ruled that President Jacob Zuma violated the constitution when he failed to repay some of the government money used to upgrade his private home.
The treasury had 60 days to determine how much he should repay, it added.
The ruling is a victory for the opposition, which said it would push for Mr Zuma’s impeachment.
It accused him of using “ill-gotten wealth” to upgrade his home with a swimming pool and amphitheatre.
Mr Zuma denied any wrongdoing. He has not yet commented on the ruling.
An anti-corruption body, known as the public protector, ruled in 2014 that $23m (£15m) had been spent on his rural home in Nkandla in South Africa’s KwaZulu-Natal province.
Mr Zuma had “unduly benefited”, and should repay a portion of the money, the public protector said.
In a unanimous judgement, the Constitutional Court said Mr Zuma’s failure to heed the directive was “inconsistent” with the constitution.
“The president failed to uphold, defend and respect the constitution of the Republic,” it added.
The case was brought by two opposition parties, the Economic Freedom Fighters (EFF) and the Democratic Alliance (DA).
Mr Zuma’s conduct constituted “grounds for impeachment”, the DA said in its reaction to the judgement.