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 has denied the allegation.
An anti-corruption body, known as the public protector, ruled in 2014 that he had "unduly benefited" from the upgrades at his home in his rural village of Nkandla.
He should pay back some of the $23m (£15m) the government spent on the upgrades.
In a unanimous judgement, the Constitutional Court said that Mr Zuma's failure to repay the money was "inconsistent" with the constitution.
"The president failed to uphold, defend and respect the constitution of the Republic," it added.