President Jacob Zuma has apologised to South Africans in an effort to end to a long-running scandal over improper state spending at his private home.
“The matter has caused a lot of frustration and confusion, for which I apologise,” he said in a TV address.
He said he would abide by a court ruling that he must repay government money spent on upgrading his rural home with a swimming pool and amphitheatre.
The case was brought by the opposition, which urged him to stand down.
The public protector, an anti-corruption body, ruled in 2014 that $23m (£15m) of public money had been improperly spent on Mr Zuma’s rural home in Nkandla in KwaZulu-Natal province, and ordered him to reimburse part of the expense.
In Thursday’s unanimous judgement, the Constitutional Court ruled that Mr Zuma’s failure to repay the money violated the constitution.
In his live address on Friday, Mr Zuma said: “I respect the judgement and will abide by it.”
The president added that he had acted “in good faith” and “never knowingly and deliberately set out to violate the constitution”.
“Any action that has been found not to be in keeping with the constitution happened because of a different approach and different legal advice,” he said, before issuing an apology for the “frustration” caused.
Analysis: Pumza Fihlani, BBC News, Johannesburg
He has been described as the quintessential escape artist, and he has done it again. South Africans were glued to their TV screens awaiting an address. Speculation was rife that the president would resign. Instead people got an apology, the first since the Nkandla saga erupted six years ago.
The immediate reaction for many is disappointment. Remember though that Mr Zuma is a master tactician who rose to the highest office against all odds. He is not about to let that go without a fight.
True to his smoothness, Mr Zuma peppered his address with denials and promises to never allow this to happen again. He even spoke about how this could only make the country stronger.
The man that has been the cause of anger for many presented himself as a victim of unclear rules, but said that he now knows better and that the country should forgive him and move on. It takes a lot of charm and confidence to display such boldness, and the president lives to fight another day.
Mr Zuma has been in office since 2009, and his government has been widely accused of corruption and cronyism.
The case had been brought by two opposition parties, the Economic Freedom Fighters (EFF) and the Democratic Alliance (DA).
The EFF urged Mr Zuma to step down and the DA called for his impeachment.
Following the president’s address, Gwede Mantashe, secretary-general of Mr Zuma’s ANC party, described the calls as an “overreaction” by the opposition.