South Africa captain Faf du Plessis hit a 46-ball century in his team’s total of 231 for seven — their second highest total in the shortest form of the game.
But it was overhauled with four balls to spare on a record-breaking day at the Wanderers with West Indies captain Darren Sammy finishing the match with a six to take his team to 236 for six.
Man of the match Gayle was again the star for the West Indies as he shared a second wicket stand of 152 off 75 balls with Marlon Samuels, who made 60.
“Cricket was the winner today,” said Sammy. “We were dominated in the Tests but we have different energy in this series.”
It was astonishing batting by both teams in ideal conditions on a field where the world record 50-overs run chase was achieved by South Africa when they scored 438 for nine against Australia in 2005/06.
The previous T20 record chase was 211 for four by India against Sri Lanka in Mohali in 2009/10.
Du Plessis said his South African record score of 119 off 56 balls was “bittersweet”.
He added: “I said at half-time that this game is very far from finished. Nothing is out of reach. Chris played so well up front, it is very hard to contain him.”
The tempo of the match was set when Du Plessis and David Miller (47) put on 103 off 49 balls for South Africa’s third wicket.
Du Plessis hit five sixes and 11 fours, while Miller’s three sixes and four fours off 26 balls included arguably the biggest hit seen at the ground, a mighty blow over long-on which cleared a four-tier grandstand and sailed into an adjacent golf course.
The West Indies replied with even more brutality at the start of their innings.
They raced to 86 for one in the six-over power play, with Gayle and Samuels posting a fifty partnership off 21 balls.
Gayle, who hit a 17-ball half-century in the first match in Cape Town on Friday, was only marginally slower on Sunday, reaching the mark off 20 deliveries with three sixes and seven fours.
The carnage continued, with Gayle bludgeoning the bowling, while Samuels managed to play with more classical control despite scoring his 60 off 39 balls with seven fours and two sixes.
South Africa were still in with a chance when medium-pacer David Wiese had Gayle caught behind in the 14th over and followed up with the wickets of Samuels and Kieron Pollard, both caught at long-on, in his next over.
At that stage the West Indies still needed 47 off 25 balls.
Two more wickets fell but Sammy clinched the win by hitting an unbeaten 20 off seven balls, finishing the match by slamming Marchant de Lange into the crowd beyond midwicket.
South African opening bowler Kyle Abbott conceded a world record 68 in his four overs.
The previous highest was 64 by Jimmy Anderson of England and Sanath Jayasuriya of Sri Lanka.