The 34-year-old has played in 114 Test matches, 228 one-day internationals and 78 Twenty20 matches for the Proteas.
He took time away from Test cricket in 2017, missing the series against England that summer, but returned to the red-ball side in December.
“I’ve had my turn and, to be honest, I’m tired,” he said.
“This is a tough decision. I’ve thought long and hard about it and I’d like to retire still playing decent cricket.
“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 green and gold, it must be everything or nothing.”
De Villiers made his international debut in the Test series against England in 2004 and played in a limited-overs match a year later.
He scored 8,765 Test runs for South Africa and has a batting average of over 50 in both Test and ODI cricket.
I’ve made a big decision today pic.twitter.com/In0jyquPOK
— AB de Villiers (@ABdeVilliers17) May 23, 2018
De Villiers’ 22nd – and final – Test century came against Australia in March.
A former Test captain, he holds the record for the fastest one-day century, reaching three figures in just 31 balls against West Indies in January 2015.
He also holds the record for the fastest Test century by a South African, making 100 from 75 balls against India in 2011.
“AB is one of the all-time greats of South African cricket who has thrilled spectators around the world,” Cricket South Africa president Chris Nenzani said.
“It goes without saying that he is going to be greatly missed wherever international cricket is played.”
His final appearance for South Africa came in Johannesburg, where the Proteas beat Australia by 492 runs and clinched the series 3-1.
He kept wicket on occasion and recently featured for Royal Challengers Bangalore in the Indian Premier League.
De Villiers added in his video message that he has “no plans” to play overseas, and he hopes to continue to be available for domestic cricket in South Africa.