Wicketkeeper-batsman Quinton de Kock stepped down from both roles.
Bavuma, a 30-year-old top-order batsman, becomes the first Black African captain of South Africa and will be in charge for one-day internationals and Twenty20s until after the Cricket World Cup in 2023, Cricket South Africa said.
“Captaining the Proteas has been a dream of mine for many years as those closest to me would know,” he said in a statement from CSA.
Opening batsman Elgar has played 67 tests and had been touted as a permanent captain in tests. He had previously stepped in for former captain Faf du Plessis in five-day cricket. Bavuma will be Elgar’s vice captain in tests.
Longtime skipper du Plessis quit as test captain last year and retired from tests this year. De Kock had taken charge of the test team temporarily.
Although he was always only a temporary test captain, de Kock’s decision to give up the limited-overs captaincy, which he was awarded in 2019, was unexpected. He was granted a break from cricket last month following the tour to Pakistan, with reports saying he wanted time to look after his mental health after living in restrictive bio-bubbles for prolonged periods while cricket series took place during the coronavirus pandemic.
“We expect him to still play an integral role in the team’s leadership group,” CSA director of cricket Graeme Smith said of de Kock.