The highest court in South Africa has ruled that President Jacob Zuma violated the constitution when he failed to repay government money spent on his private home.
It gave the treasury 60 days to determine how much he should repay.
The ruling is a victory for the opposition, who said they would push for Mr Zuma's impeachment.
They accuse him of using "ill-gotten wealth" to upgrade his home with a swimming pool and amphitheatre.
Mr Zuma has denied any wrongdoing.
A government statement said he would "reflect" on the judgement and take "appropriate action".
A spokeswoman for the governing African National Congress (ANC) said the party's top six officials, who include Mr Zuma and his deputy Cyril Ramaphosa, would meet to discuss the implications of the ruling, Reuters news agency reports.
A former top ANC official Mathews Phosa called for the president to step down.
"The whole country now waits with bated breath to hear whether he, and my party, the ANC, will do the right thing and relieve us of this crippling nightmare," he said.
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" from the renovations and should repay a portion of the money, the public protector said.
In a unanimous judgement on behalf of the Constitutional Court's 11 judges, Chief Justice Mogoeng Mogoeng said the public protector was a "Biblical David" fighting against the Goliath of corruption.
Mr Zuma's failure to repay the money was "inconsistent" with the constitution, he added.
"The president failed to uphold, defend and respect the constitution," he declared.
Mr Mogoeng added that public officials ignored the constitution at their peril, and should remember that the rule of law was the "sharp and mighty sword that stands ready to chop the ugly head of impunity from its stiffened neck".
What Mr Zuma must pay for
- Swimming pool
- Visitor centre
- Cattle enclosure
- Chicken run
The court also condemned the ANC-dominated parliament for failing to hold Mr Zuma accountable.
The case was brought by two opposition parties, the Economic Freedom Fighters (EFF) and the Democratic Alliance (DA).
The EFF called on Mr Zuma to step down while the DA said it would table a motion in parliament to demand his impeachment.
Mr Zuma's term in government has been marred by allegations of corruption and cronyism.
Analysis: Milton Nkosi, BBC Africa, Johannesburg
It is very difficult to see how the ANC can continue to have President Zuma at the helm, following the stinging rebuke he received from the Constitutional Court.
Opposition parties now plan to strike against the 73-year-old leader, and hope that ANC MPs will vote with them to impeach him. Another option is for the ANC to recall Mr Zuma, as it did with his predecessor, Thabo Mbeki, in 2008.
A third option would be to say "better the devil you know" and to stick with Mr Zuma, at least until after this year's crucial local government elections.
As for South Africans, they are celebrating the independence of the Constitutional Court. It has shown that it will protect the public from the abuse of power and will not be a political crony of the government.
This is likely to embolden South Africans to continue fighting corruption and demanding accountability from the government.