Faf du Plessis has stepped down as South Africa Test and Twenty20 captain, saying it is in the teams' "best interests".
The 35-year-old batsman captained the Proteas in 112 matches across all formats since 2012, scoring 5,101 runs - including 11 centuries - as skipper.
Quinton de Kock replaced Du Plessis as one-day captain in January.
In a statement, Du Plessis said stepping down was "one of the toughest decisions to make".
He was rested for both the recent one-day international and T20 series against England, and in January denied reports he would retire after the Test series, saying the timeframe he was looking at was the Twenty20 World Cup, which runs from 18 October to 15 November.
On Monday, he was named in South Africa's squad for the three-match T20 series against Australia, which starts on Friday.
He added: "The last few weeks of rest away from the game have given me a lot of perspective on the great privilege and honour I have had in representing and leading my country in the three formats of this wonderful game.
"It has been a rewarding, sometimes tough and other times a lonely road, but I would not replace the experience for anything, because it has made me the man that I am proud to be today.
"As the team heads into a new direction, with new leaders and a young crop of players, I feel it will be in the best interests of South African cricket to relinquish the captaincy in all formats."
After first captaining South Africa in a T20 series against New Zealand in 2012, Du Plessis was named permanent T20 skipper in 2013. In 2017, he assumed full-time captaincy of all three formats, replacing AB de Villiers.
Du Plessis scored 115 runs at an average of 16.42 in the Test series against England and has not made a century for more than a year.
"I have strived to lead the team with dignity and authenticity during exhilarating highs and devastating lows," said Du Plessis.
"I have never been one to throw in the towel and do believe I am putting the team first.
"In a perfect world I would have loved to lead the team in the Tests for the rest of the season, as well as the T20 World Cup - but sometimes the most important attribute of a leader is to be selfless.
"I am healthy, fit, energised and motivated and certainly see myself playing an important role in the squad for as long as I continue putting in winning performances for the team."