The newcomers shared an eighth wicket stand of 74 to rescue Pakistan from a precarious 131 for seven, then shared five wickets as Pakistan won by 23 runs.
Pakistan made 218 for nine in their 50 overs after winning the toss. Despite a half-century from returning veteran Jacques Kallis, South Africa were bowled out for 195.
Bhatti (39) and Ali (43 not out) prospered after Pakistan's recognised batsmen struggled against a strong South African pace attack.
Bhatti, 22, took three for 37 in South Africa's innings, while Ali, 25, claimed two for 24, including the crucial wicket of Kallis, bowled for 50. Bhatti and Ali shared the man of the match award and earned high praise from captain Misbah-ul-Haq.
"I am very happy, especially as the two youngsters set it up. The plan was to negotiate the new ball, then accelerate but we kept losing wickets at the wrong time. It was not a good total but the bowlers did really well," said Misbah.
For the first time since South Africa began their rise to the top of the Test rankings, the hosts fielded all three of their leading fast bowlers - Dale Steyn, Vernon Philander and Morne Morkel - in the same one-day side.
With Kallis returning for his first one-day international since February 2012, South Africa applied relentless pressure as Pakistan struggled. But Bhatti and Ali, who have both scored first-class centuries despite primarily being picked as bowlers, went for their shots to keep their side in the game.
Steyn took three for 33 and Morkel three for 39, while Philander claimed one for 37. Bhatti and Ali put on 74 off 70 balls. Bhatti made his 39 off 25 balls, hitting three fours and two sixes, while Ali hit six fours in a 55-ball innings.
"We spoke about batting out the 50 overs," said Ali. "We have played together a lot in domestic cricket so that helped." South Africa suffered an early blow when Hashim Amla exposed his leg stump and was bowled by Junaid Khan in the third over of their innings.
Graeme Smith followed in the next over, stumped by Umar Akmal off Mohammad Hafeez, although it was a fortuitous dismissal for the wicketkeeper as the ball bounced off his gloves, onto the ground and into the stumps while Smith's foot was momentarily off the ground.
Kallis and Quinton de Kock put on 42 for the third wicket before De Kock was bowled by Bhatti.
Batting with calm assurance, Kallis reached 50 for the 103rd time in one-day internationals but was then bowled by Ali, edging an in-swinging delivery from Ali off the bottom of his bat into the stumps. When David Miller edged Ali to Akmal, South Africa were 123 for six.
JP Duminy made 49 before he was caught behind, attempting a reverse sweep against Saeed Ajmal and Bhatti claimed the last two wickets to seal a memorable win for the tourists, who were beaten 4-1 by the same opponents in a recent series in the United Arab Emirates.
"The bowlers did a brilliant job in getting them seven down but we let it slip at the end," said South African captain AB de Villiers.