Elgar had made his debut for South Africa in 2012.
The 36-year-old's decision was communicated by Cricket South Africa on Thursday (December 22) and he will finish with more than 80 Tests, scored over 5000 runs, and led the Proteas 17 times in the longest form of the game.
"As they say, 'all good things come to an end', and the Indian home series will be my last, as I have decided to retire from our beautiful game. A game that has given me so much. The Cape Town Test will be my last. My favorite stadium in the world. A place I scored my first Test run against New Zealand and hopefully my last too," Elgar was quoted as saying in a CSA release.
Rohit Sharma a question mark in T20 cricket as batter: Manjrekar's bold remark on former MI skipper
"Playing the game of cricket has always been a dream of mine but having the opportunity to represent your country is the ultimate. Having had the privilege to do it for 12 years internationally is simply beyond my wildest dreams. It has been an incredible journey that I have been fortunate enough to have,” he added.
With 5146 runs, Elgar is South Africa's eighth-highest run-scorer in Test cricket - and only eight have gone past 5,000 runs - and 352 runs behind Mark Boucher who is seventh on the list.
Elgar began his Test career in the South Africa middle-order in the Perth Test of 2012 and infamously bagged a pair of ducks despite having forced his way into the team after averaging nearly 60 in first-class cricket over the preceding two years. An unbeaten 103 in Gqeberha against New Zealand two Tests later set him rolling.
ESPNCricinfo has reported that Elgar was informed that he is not part of red-ball coach Shukri Conrad's long-term plans. Elgar has been linked with Essex as an overseas player for the 2024 season.
Elgar is said to have been dissatisfied with the decision to stand down, but he accepted a new central contract at the end of March. Elgar understood his Test career would be limited by the schedule, with South Africa only playing two-Test series in the 2023-2025 WTC cycle, and sources indicated he wanted to leave on a high at home.
(PTI/ICC inputs)