South Africa coach Mark Boucher will leave his post after the Twenty20 World Cup in Australia later this year to pursue "other opportunities in line with his future career and personal objectives", officials have said.
It means the Proteas will have a new coach in place for the three Tests in Australia starting in December.
Monday's announcement came hours after South Africa lost their three-match Test series in England.
Former wicketkeeper Boucher, who played 147 Tests for South Africa, has been in the role since December 2019 and had been contracted until the end of the 2023 50-over World Cup in October next year.
"We would like to thank Mark for the time and effort he has invested in South African cricket as the head coach over the past three years," Cricket South Africa CEO Pholetsi Moseki said.
"He has helped navigate us through some rough waters following the departures of so many senior players through retirement and has helped lay some strong foundations for the next generation of Proteas."
n May, CSA charges of gross misconduct and racism against Boucher were formally and unreservedly withdrawn. They related to allegations involving his former team-mate Paul Adams and an investigation into the resignation of his former assistant coach Enoch Nkwe.
But both Adams and Nkwe decided against giving testimony, leaving CSA to conclude that there was "no basis to sustain any of the disciplinary charges", as Boucher was allowed to continue as head coach.
Nkwe, now CSA director of cricket, said of Boucher's impending departure: "We are deeply saddened by Mark's decision to leave us but we also understand and respect his wishes. He is a Proteas legend and has done so much for the game in our country, both on the field and over the last three years off it."
Boucher has generally won praise for improving South Africa's Test and white ball cricket, though the recent five-day series in England was woeful for the batsmen with no quick fix to that problem in sight.
The highlight of his tenure to date was a home Test series win over India in January, which has helped South Africa reach second place in the ICC Test World Championship table.