Miller clubbed two towering blows over midwicket and into the stands off Lahiru Kumara as the Proteas successfully chased down their target of 143 with one ball and four wickets to spare.
Sharjah: Sri Lanka 142, South Africa 146-6 - South Africa won by four wickets
David Miller struck two sixes in the final over as South Africa kept their T20 World Cup hopes alive with a dramatic win over Sri Lanka in Sharjah.
Miller clubbed two towering blows over midwicket and into the stands off Lahiru Kumara as the Proteas successfully chased down their target of 143 with one ball and four wickets to spare.
It had seemed as though South Africa's tournament would be hanging by a thread when they were left needing 25 from the final two overs, with Miller and Kagiso Rabada at the crease.
But Rabada struck a six in the penultimate over to keep victory within reach, and Miller did not lose his nerve, dispatching two length deliveries from Kumara over the rope.
Earlier, Sri Lanka were indebted to Pathum Nissanka for putting together a score of some substance.

Pathum Nissanka made a half-century for Sri Lanka against South Africa
The 23-year-old displayed the fearlessness of youth in taking on a dangerous South African attack, upping his scoring rate following the loss of Charith Asalanka and showing a willingness to target every boundary in making 72 from 58 balls.
One Rabada over went for 17 runs, as Nissanka ended up with more than half of his team’s total.
Tabraiz Shamsi and Dwaine Pretorius both returned figures of 3 for 17 - Shamsi from four overs, Pretorius from three - as the Sri Lankan middle order came and went like commuters in a coffee shop.
For much of the second half of this match, Nissanka’s innings appeared likely to be enough to give his bowlers the platform to deliver a crucial win in their pursuit of a place in the last four.
South Africa found the going tough on a pitch which proved to be a great leveller between bat and ball.
Quinton de Kock, restored to the Proteas line-up after making himself unavailable for selection against West Indies earlier in the week, was caught off a no ball early in the reply but did not make the most of the opportunity and sent a simple return catch to Dushmantha Chameera.

David Miller hit two sixes in the final over
Reeza Hendricks, Rassie van der Dussen and Aiden Markram all got themselves set but none could go past 20, and the weight of the chase was left to fall on the shoulders of captain Temba Bavuma.
After a sluggish start, Bavuma looked to be finding rhythm but when he clipped Wanindu Hasaranga to Nissanka on the midwicket boundary, things fell apart.
Hasaranga went on to complete a hat-trick, just the third in the history of the men’s T20 World Cup, by dismissing Pretorius, and with Rabada on strike and 25 required from 12 balls, the odds had swung in Sri Lanka's favour.
But T20's ebb and flow can be incredibly unpredictable. And so it proved once again.
T20 World Cup Hub: News, analysis, stats, live scores
RELATED STORIES
Pathum Nissanka gives Sri Lanka sight of a bright future
Subscribe to The Cricketer for exclusive content every day: The inside track on England's Test tour with George Dobell in Pakistan, award-winning analysis, breaking news and interviews and the only place for in-depth county coverage all year round. Plus: An ad-free app experience at your fingertips. Subscribe to thecricketer.com today for just £1.