Electing to bat, Dhoni bailed India out of trouble with his 86-ball knock to take the team to 247 for nine. His bowlers then ended the visiting side's innings at 225 to record their first win on South Africa's current tour. (Lot of people wait with open swords: Dhoni)

Dhoni plays a shot on way to 92 not out

Going through the toughest phase of his international career, Dhoni played a captain's knock and then made smart bowling changes to bundle out South Africa in 43.4 overs.

Axar Patel (3/39) and Bhuvneshwar Kumar (3/41) shared six wickets between them, while Harbhajan Singh (2/51) scalped two in his comeback match.

The nudges, quick singles, shot-arm jabs, pulls, cuts, lofted shots over the bowlers' heads - all were on full display as Dhoni answered his critics with a knock that was decorated with seven boundaries and four sixes.

'Captain Cool' batted with the tail-enders with a calm head as India scored 82 runs off the last 10 overs to put on board a decent total, which at one stage looked impossible.

India were looking down the barrel at 165 for seven in the 40th over, but Dhoni found great support from Harbhajan Singh (22), with whom he added 56 runs.

Ajinkya Rahane yet again batted well, scoring a 63-ball 51 for his second consecutive half century. For South Africa, Dale Steyn (3/49) picked up three wickets, while Morne Morkel and Imran Tahir scalped two apiece.

South Africa started their chase on a quick note, stitching a run-a-ball 40-run partnership for the opening wicket between Hashim Amla (17) and Quinton de Kock (34). De Kock was the aggressor of the two but was lucky as a diving Rohit Sharma spilled a tough chance off Umesh Yadav in the fourth over.

Rohit Sharma is bowled by Kagiso Rabada (not in picture)

With both his frontline pacer proving ineffective, Dhoni introduced spin from both ends in the sixth over. The move yielded instant result when Axar had Amla stumped after the batsman danced down the wicket.

De Kock was going great guns with five boundaries when he fell for one too many, caught by Mohit Sharma at long-off off Harbhajan, leaving the Proteas at 52 for two inside the 10th over.

The fall of two quick wickets hardly bothered Faf du Plessis (51) and JP Duminy (36) as the duo batted with ease to keep the asking rate in control.

The duo brought up South Africa's 100 in 19.5 overs and shared 82 runs off 87 balls for the third wicket to keep the visitor's in the hunt.

But just when it seemed the match was going out of India's grasp, Axar picked up the wickets of Duminy and Du Plessis in consecutive overs to bring the hosts back in contention.

Patel trapped Duminy in front of the wicket and then dismissed Du Plessis in his next over, caught by Virat Kohli at covers.

Bhuvneshwar made it triple delight for India in the next over when he induced an edge from David Miller and Dhoni took a fine diving catch to reduce South Africa to 142 for five.

South Africa skipper De Villiers made 19 off 20 balls before Kohli took a brilliant diving catch off Mohit. Farhaan Behardien kept South Africa in the game in the company of Steyn and Kagiso Rabada but Behardien got a dubious caught behind decision from umpire Vineet Kulkarni beforeKumar polished off the tail with two wickets in the 44th over.

Earlier electing to bat, the hosts suffered a big setback in the form of Rohit Sharma, who was cleaned up by young paceman Kagiso Rabada the second over of the day.

Shikhar Dhawan (23) and Rahane then played cautiously to resurrect the Indian innings with a 56-run second wicket stand.

With the two batsmen finding it difficult to get the boundaries after the early dismissal of Rohit, Dhawan finally broke the shackles with a splendid cover drive off Rabada inthe fourth over.

Rahane was not to be left behind as he showed his class by driving on the up, cutting and flicking Morne Morkel for three boundaries in the next over.

Dhoni raises his bat after completing half century

De Villiers introduced part-time off-spinner JP Duminy into the attack in the 12th over and Dhawan welcomed the bowler in style, pulling a loosener to the midwicket boundary.

But just when it looked Dhawan was slowly getting back his mojo, the left-hander once again gave away his wicket after getting a start. It was a soft dismissal as Dhawan chipped a slow off-cutter from Morkel straight to Duminy at short cover.

To add to India's woes, Kohli's (12) unlucky run continued as he became a victim of a horrible mix up. In the last ball of the 18th over by Morkel, Rahane was dropped by a diving Farhaan Behardein at mid-off following which the batsmen take a single.

Kohli wanted a second run and sprinted back but Rahane stood his ground at the non-striker's end holding his hand up in the air and in the process both the batsmen ended up at the same end and the bails were whipped off by wicketkeeper Quinton de Kock at the other side.

A livid Kohli had no option but to leave the ground A livid Kohli had no option but to leave the ground distraught, paving the way for an under-pressure Dhoni to take control of the innings.

Rahane brought up his second consecutive fifty in 59 balls with a cheeky four off Morkel over the keeper's head.

But after doing all the hard work, Rahane would be cursing himself as when India needed him to play a big innings, especially after the Kohli mix-up, he too threw away his wicket. He was bowled around the legs by leg-spinner Tahir in the 23rd over as the batsman went for the sweep shot.

Suresh Raina did not disturb the scorers. The left-hander completely looked at sea against Morkel during his brief five-ball stay and was eventually caught down the leg side by De Kock for a duck as India slumped to 105 for five in 23.4 overs.

Indian players celebrate a wicket

Axar (13), brought into the side in place of Amit Mishra for his all-round abilities, gave Dhoni brief company and in between struck the first six of Indian innings in the 29th over before he was out LBW to Steyn as wickets kept tumbling from one end.

Bhuvneshwar (14), too, gave Dhoni good support down the order as the duo shared 41 runs for the seventh wicket to keep India's scoreboard ticking before he was cleaned up by Tahir.

Harbhjan, who replaced an injured Ravichandran Ashwin, made a run-a-ball 22 and provided good support. Dhoni brought up his 60th ODI fifty with a six off Duminy.

With last man Mohit Sharma at the other end, Dhoni took most of the strike and in the final over after five dot balls, finished off the innings in style, clobbering Rabada over the square-leg fence.