It had looked as if Jos Buttler's woes as England captain were going to continue as England slumped to 41-2 after less than five overs.
A much-needed 43 from Dawid Malan helped stop the rot for England, but it was Bairstow and Ali who stole the headlines in Bristol.
Firstly Bairstow, whose incredible summer continues, with the Yorkshireman racking up a stellar 90 from just 53 balls.
He was joined at the crease by all-rounder Ali, who recorded the fastest ever half-century for an England player in T20 cricket, scoring 50 runs off just 16 balls.
With a total of 234 at the interval, a victory looked to be in England's hands, not least after a commanding start from the hosts with ball in hand saw South Africa reduced to 7-2 inside the second over.
Bit-part knocks from South Africa's middle order did little to help, until Tristan Stubbs took the run-chase by the horns, scoring a half-century of his own.
Ultimately, the tourists would fall just short, with the 21-year-old Stubbs departing for 72 off 28 balls and South Africa finishing their innings on 193-8.
Despite the bruising defeat, there were positives for South Africa to take from the match, with Stubbs's eye-catching knock complemented by Lungi Ngidi's five-wicket haul.
With such a quick turnaround, South Africa will enter the second T20 clash with England in the knowledge that anything but a victory will see the series slip out of their grasp.
Just 24 hours separates the first match with the second, which while may not be uncommon for T20 fixtures to come in such quick succession, captain Buttler will no doubt look to make changes to his side.
Phil Salt could be in line for a start, with England's top order having shown signs of vulnerability in recent weeks.
Whether he is joined by Lancashire teammate Richard Gleeson remains to be seen, after the 34-year-old continued his impressive summer for England by taking three more wickets on Wednesday.
Catching some by surprise with his performance in Bristol in the first match, Stubbs will likely be handed the chance to build on his total of 72 with another start in Cardiff.
Star man Quinton de Kock managed just two runs before giving his wicket away in the first game, with the opening batsman likely to take the first strike once again on Thursday.
Stand-in captain David Miller will hope to provide muscle in the middle having slumped to a defeat in his first game as skipper.
England squad: Jos Buttler (c, wk), Moeen Ali, Jonathan Bairstow, Harry Brook, Sam Curran, Richard Gleeson, Chris Jordan, Liam Livingstone, Dawid Malan, Adil Rashid, Jason Roy, Phil Salt, Reece Topley, David Willey
South Africa squad: David Miller (c), Gerald Coetzee, Quinton de Kock (wk), Reeza Hendricks, Heinrich Klaasen, Keshav Maharaj, Aiden Markram, Lungi Ngidi, Anrich Nortje, Wayne Parnell, Andile Phehlukwayo, Dwaine Pretorius, Kagiso Rabada, Rilee Rossouw, Tabraiz Shamsi, Tristan Stubbs, Rassie van der Dussen
Series so far
First T20: England won by 41 runs
England 234-6 (20.0)
South Africa 193-8 (20.0)
We say: South Africa to win
A welcome victory for Buttler and co, given how the previous white-ball matches against South Africa and India had gone, England will be looking to build on that victory with another in Cardiff.
Fatigue could play its part, and with South Africa seeking vengeance after Wednesday's battering, expect the tourists to bounce back fighting.