“After 114 test matches, 228 one day internationals and 78 T20 internationals it is time for others to take over. I’ve had my turn and to be honest I’m tired,” he said in a video message on Twitter and in a statement.
“This is a tough decision, I have thought long and hard about it and I’d like to retire while still playing decent cricket. After the fantastic (test) series wins against India and Australia, now feels like the right time to step aside.
“It would not be right for me to pick and choose where, when and in what format I play for the Proteas. For me, in the green and gold, it must be everything or nothing,” he added.
The 34-year-old, whose swashbuckling batting style and razor sharp fielding has made him one of the sport’s leading lights, only returned to test cricket in December after a lengthy hiatus where he focused on the limited overs formats of the game.
“It’s not about earning more somewhere else, it’s about running out of gas and feeling that it is the right time to move on,” he said. “Everything comes to an end. To the cricket fans around South Africa and the world, thank you for your kindness and generosity, and today, for your understanding.
“I have no plans to play overseas, in fact, I hope I can continue to be available for the Titans in domestic cricket. I will continue to be the biggest supporter of (captain) Faf du Plessis and the Proteas.”
De Villiers retires with a test average of 50.66 and as the fourth-highest scorer for South Africa with 8,765 runs. He made 22 test centuries.
In ODI cricket, he holds the records for the fastest 50 (16 balls), 100 (31 balls) and 150 (64 balls).
“AB is one of the all-time greats of South African cricket who has thrilled spectators around the world with his sheer brilliance, coupled to his ability to innovate and take modern day batting in all three formats but particularly in the white ball ones to new levels,” said Cricket South Africa president Chris Nenzani.