Babar Azam's century set up Pakistan's three-wicket victory over South Africa in the first one-day international on Friday, although the tourists still needed to scramble a run off the final ball to win.

The Pakistan captain hit 103 off 104 balls and his team was cruising at 186-1 at SuperSport Park after South Africa scored 273-6 in its 50 overs.

More Images
Pakistan's captain Babar Azam watches his shot during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Babar Azam's century set up Pakistan's three-wicket victory over South Africa in the first one-day international on Friday, although the tourists still needed to scramble a run off the final ball to win.

Pakistan's captain Babar Azam, raises his helmet to celebrate scoring a century during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Still, Pakistan only needed three runs off the final over.

Off South Africa's bowler Anrich Nortje, teammates celebrate the dismissal of Pakistan's batsman Danish Aziz for 3 runs during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Azam's was the game-winning innings. He was supported by 70 from opener Imam-ul-Haq and they shared a fabulous partnership of 177 for the second wicket after Pakistan was 9-1.

South Africa's batsman Rassie van der Dussen, right, plays a shot as Pakistan's wicketkeeper Mohammad Rizwan watches on during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Earlier, Pakistan put South Africa in to bat and made instant progress to have the home team struggling at 55-4.

South Africa's batsman Rassie van der Dussen raises his bat to celebrate scoring a century during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

More AP sports: https://apnews.com/apf-sports and https://twitter.com/AP_Sports

Azam's dismissal sparked a slump as Pakistan lost four wickets for 17 runs, all of them to fast bowler Anrich Nortje.

Pakistan's captain Babar Azam watches his shot during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Pakistan's captain Babar Azam watches his shot during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Still, Pakistan only needed three runs off the final over.

But Shadab Khan (33) fell to the first ball of that last over and South Africa seamer Andile Phehlukwayo bowled another three dot balls to heighten the tension.

Faheem Ashraf finally made contact off the fifth ball with a chip over the bowler's head for two. He flicked the final ball of the game through the covers for a single to reach 274-7 and put Pakistan 1-0 up in the three-game series.

Pakistan's captain Babar Azam, raises his helmet to celebrate scoring a century during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Pakistan's captain Babar Azam, raises his helmet to celebrate scoring a century during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Azam's was the game-winning innings. He was supported by 70 from opener Imam-ul-Haq and they shared a fabulous partnership of 177 for the second wicket after Pakistan was 9-1.

Nortje's burst of four wickets threatened to undo the work of Azam and Imam as Pakistan slipped to 203-5.

Mohammad Rizwan led the recovery with his 40, and Shadab's contribution at the end was also vital.

Off South Africa's bowler Anrich Nortje, teammates celebrate the dismissal of Pakistan's batsman Danish Aziz for 3 runs during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Off South Africa's bowler Anrich Nortje, teammates celebrate the dismissal of Pakistan's batsman Danish Aziz for 3 runs during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

Earlier, Pakistan put South Africa in to bat and made instant progress to have the home team struggling at 55-4.

South Africa's innings was rescued by 123 not out from Rassie van der Dussen and 50 by David Miller. The Proteas' total was still below par.

South Africa was being led by new limited-overs captain Temba Bavuma for the first time. Bavuma made history as the first Black African to be appointed captain of South Africa.

South Africa's batsman Rassie van der Dussen, right, plays a shot as Pakistan's wicketkeeper Mohammad Rizwan watches on during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

South Africa's batsman Rassie van der Dussen, right, plays a shot as Pakistan's wicketkeeper Mohammad Rizwan watches on during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

More AP sports: https://apnews.com/apf-sports and https://twitter.com/AP_Sports

South Africa's batsman Rassie van der Dussen raises his bat to celebrate scoring a century during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)

South Africa's batsman Rassie van der Dussen raises his bat to celebrate scoring a century during the One Day International cricket match between South Africa and Pakistan at Centurion Park in Pretoria, South Africa, Friday, April 2, 2021. (AP PhotoThemba Hadebe)