Duminy was dropped from the Proteas squad after the first Test at Lord's in a four-match series against England in July and has since not featured in the longest format.
In 46 Tests, Duminy scored 2,103 runs at an average of 32.85.
He also picked up 42 wickets with his off-spin.
"After long and careful deliberation, I have decided to retire from first-class and Test match cricket with immediate effect," said Duminy, who opted out of the opening round of domestic first-class fixtures in South Africa.
"It is an experience that cannot be replaced and one I will always cherish. Test cricket has always been the pinnacle and I've been fortunate enough to experience some memorable highlights with the Proteas and also in first-class matches with the WSB Cape Cobras," he added.
Duminy made his Test debut with an unbeaten half-century at Perth against Australia in 2008 to help South Africa hunt down a target of 414, the second-highest successful run-chase in Test cricket.
"In the years ahead, my focus will be placed on attaining limited-overs cricket success for South Africa and the WSB Cape Cobras..." he added.
South Africa's next Test assignment is a two-match home series against Bangladesh from September 28.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ