"It's been an honour and a privilege to have been part of the South African test team since making my debut 18 years ago," said the 38-year-old, who has amassed 13174 runs and taken 292 wickets from 165 tests.
"I have enjoyed every moment out in the middle but I just feel that the time is right to hang up my test whites," said the all-rounder who has also accumulated 11574 runs from 325 one-day internationals.
"It wasn't an easy decision to come to, especially with Australia around the corner and the success this team is enjoying, but I feel that I have made my contribution in this format."
After the first test ended in a draw, world number one Proteas take on India in the second and final test on Thursday.
They will host Australia for three tests and as many Twenty20 internationals in a series starting in February.
(Writing by Sudipto Ganguly; editing by Amlan Chakraborty)
