Smith resurrected the team from the match-fixing scandal involving former skipper Hansie Cronje and a disastrous World Cup on home soil in 2003.
Smith, given control of the underperforming and fiercely criticized national team at 22, went on to play over 100 tests, was captain for more than a decade and established South Africa as the No. 1 test team in the world, although he couldn't end the country's long wait for a World Cup title.
''This has been the most difficult decision I have ever had to make in my life,'' Smith said in a statement through Cricket South Africa.
He told teammates after the third day of the ongoing third test against Australia at his home ground Newlands in Cape Town that he was retiring after the match.
''It's a decision that I have been considering since my ankle surgery in April last year,'' he said. ''I have a young family to consider, and I felt that retiring at Newlands would be the best way to end it because I have called this place home since I was 18 years old.''
CSA said it was surprised by Smith's announcement but recognized him as ''one of the true legends of the game.'' It follows the sudden announcement by allrounder Jacques Kallis to quit tests late last year.
''We must respect him for deciding to call time,'' CSA chief executive Haroon Lorgat said of Smith. ''Knowing him as well as I do, having been instrumental as a selector in appointing him as a young captain, he would not have taken this decision lightly or without a great deal of thought.''
The 33-year-old Smith appears to be heading for a defeat against the Australians in his final test, a result that would end the Proteas' five-year unbeaten run in test series.
He will give up all internationals after his 117th test, against the same opponents and on the same ground where he made his debut almost to the day, on March 8, 2002. He also played 197 one-day internationals, and scored over 9,000 test runs and 6,989 ODI runs.
Wicketkeeper-batsman AB de Villiers, the one-day captain, will likely be the favorite to take over as test skipper.
Smith's decision to quit just over two months after the long-serving Kallis announced his retirement on Christmas Day signals a ''new era'' in South African cricket, Lorgat said.
''I have been fortunate to have had many highs,'' Smith said, ''amongst them leading and being part of the best test team in the world. I will cherish these memories for the rest of my life. Thank you from the bottom of my heart. I bid my career a fond yet sad farewell.''
A big, muscular left-handed opening batsman, Smith never was praised for being an elegant player, but he was gritty, single-minded and at times brutish - all qualities that endeared him to a South African sporting public that like their stars to be tough, above anything else.
''I have always been someone who has left everything out there on the field for my team and for my country,'' he said.
His double-centuries in back-to-back tests in England in 2003 and early in his career announced him as a player to be reckoned with, and he had a habit of making big scores when his team had its back to the wall, not least the 90 he hit to set up South Africa's world-record score of 438 to win an ODI against Australia in 2006.
''I would like us to remember Graeme for his nerves of steel and his match-winning performances,'' Lorgat said.
Smith has scored 27 test hundreds and 38 half-centuries at an average of 48.72 with likely one innings to go.
Ahead of the series-deciding third test, which Australia leads by 234 runs with two days to play, Smith talked of a ''challenging two weeks'' in relation to his personal life and with specific reference to his young daughter. He didn't elaborate.
''I definitely don't see myself playing until the age of Kallis or (Sachin) Tendulkar,'' he said. ''But hopefully I'll know when the time is right.''