Keshav Maharaj scored the winning runs as South Africa beat Pakistan by one wicket in Chennai ©Getty Images

Keshav Maharaj scored the winning runs to clinch a thrilling one-wicket win for South Africa over Pakistan in the International Cricket Council Men's Cricket World Cup.

The result at Chennai's M. A. Chidambaram Stadium pushed the Proteas into pole position in the group stage with five wins from six games.

Aiden Markram starred with a crucial 91 runs from 93 balls to help South Africa beat Pakistan in the World Cup for the first time since 1999.

South Africa found themselves against the ropes with nine wickets lost but tailender Maharaj dispatched a winning four with 16 balls remaining to seal victory.

His side were set a target of 271 to win but lost opener, and the tournament's leading run-scorer, Quinton de Kock and captain Temba Bavuma to leave them 67-2.

It became 136-4 after Rassie van der Dussen and Heinrich Klaasen fell for 21 and 12, respectively.

David Miller and Marco Jansen then followed with 36 runs still needed and four wickets remaining.

Usama Mir then claimed the scalp of Markram who was quickly joined back in the dressing room by Gerald Coetzee.

The narrow victory puts South Africa top of the Cricket World Cup round-robin standings by two points, although they have a game in hand over India ©Getty Images
The narrow victory puts South Africa top of the Cricket World Cup round-robin standings by two points, although they have a game in hand over India ©Getty Images

A stunning one-handed catch from bowler Haris Rauf saw Lungi Ngidi head to the pavilion with 11 runs required before Tabraiz Shamsi narrowly survived a leg-before-wicket review.

Maharaj then dragged South Africa across the line with seven not out.  

In Pakistan's innings, they were shaky after captain Babar Azam departed for 50 with the total at 141-5.

Saud Shakeel then steadied the ship with 52 alongside Shadab Khan's 43.

However, South African bowler Shamsi finished with four wickets for 60 runs to falter the Pakistan attack.

"I knew I had to do a job there, but the guys who bowled before me set it up perfectly," said player of the match Shamsi.

"They're probably the first four runs I've scored this year. Kesh scored big runs and Lungi before him too."

Competition is set to continue tomorrow with a double-header, as Australia face New Zealand in Dharamsala before Bangladesh play The Netherlands in Kolkata.