LONDON — The South African president, Jacob Zuma, agreed on Wednesday to repay the government part of the $23 million in public funds that were spent on lavish improvements to his home, in an attempt to defuse a controversy that has dogged his administration and the governing party, the African National Congress.

The improvements to Mr. Zuma’s spacious homestead, just south of the town of Nkandla in KwaZulu-Natal Province, were made shortly after he took office in 2009. They included a swimming pool, a visitor center, a helipad, a cattle enclosure, an amphitheater, three houses for Mr. Zuma’s personal employees and even a chicken coop. (The government tried to justify the swimming pool by characterizing it as potential firefighting equipment.)

Mr. Zuma did not specify how much he would repay.

The government at first insisted that the home upgrades were security enhancements, and at one point, Mr. Zuma told Parliament that he had paid for the improvements himself. But late in 2012, critics filed complaints with the office of the public protector, whose job is to investigate allegations of official misconduct, and demanded an investigation.

The public protector, Thulisile Madonsela, concluded in 2014 that Mr. Zuma had misappropriated government funds, failed to stop his architect and other contractors from piling on costs, and “benefited unduly” from the renovations, in a manner “inconsistent with his office.”