The big left-hander thrashed eight sixes and five fours in a brutal assault on the South African bowlers. His innings included an extraordinary sequence during which he hit 52 runs off 11 balls - five sixes, five fours and a two.
After making only one run off the first six balls he faced, he reached his half-century off 17 balls. Only India's Yuvraj Singh, who reached his half-century off 12 balls against England in Durban during the 2007 World Twenty20, has reached 50 off fewer deliveries.
"It's a captain's nightmare," admitted South African skipper Faf du Plessis. "I thought we posted a really good total."
West Indian captain Darren Sammy said victory helped heal some of the wounds caused by South Africa's comfortable 2-0 win in the preceding three-match Test series. "We were determined to make up for the Test series," said Sammy of Friday's winning team which featured only four of the Test side.
Despite Gayle's assault, there were only four balls to spare when the West Indies completed their win by passing their target of 166. Leg-spinner Imran Tahir led the South African fightback, taking three for 28 in four overs, including the wicket of Gayle, who gloved an attempted reverse sweep to wicketkeeper Morne van Wyk.
Gayle was second man out with the total on 114 off the last ball of the 11th over. At that stage it looked as though the tourists would romp to victory. But four more wickets fell before Kieron Pollard pulled David Wiese to the midwicket boundary off the second ball of the last over.
Rilee Rossouw anchored South Africa's total of 165 for four with an unbeaten 51, made off 40 balls with five fours. The most spectacular batting of the South African innings came from Du Plessis, who hammered 38 off 20 balls, with five fours and two sixes.
West Indian left-arm opening bowler Sheldon Cottrell took two for 33, while Jason Holder opened the bowling and conceded only 20 runs in an unbroken four-over spell, while claiming the wicket of Van Wyk.