England overcame late nerves and the loss of four wickets for 20 runs to beat South Africa by two wickets in the final one-day international on Sunday and draw the series 1-1.

England was cruising at 232-4 in pursuit of South Africa's 256-7 at the Wanderers when Joe Denly's dismissal for 66 sparked the late collapse.

More Images
England's batsman Moeen Ali watches his shot to score a winning run during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England overcame late nerves and the loss of four wickets for 20 runs to beat South Africa by two wickets in the final one-day international on Sunday and draw the series 1-1.

England's batsman Adil Rashid during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England finished on 257-8 with nearly seven overs to spare for a victory that wasn't as comfortable as it should have been.

A fan watches the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's sub-par total was partly due to legspinner Adil Rashid, who was also recalled to the England team for his first appearance this tour.

South Africa's bowler Lungi Ngidi, right, celebrates the wicket of England's batsman Tom Curran for 5 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England captain Eoin Morgan won the toss and put South Africa in to bat, correctly deciding the pitch was best suited to chasing down a score.

South Africa's bowler Lungi Ngidi, left, celebrates with teammate Temba Bavuma after dismissing England's batsman Jason Roy for 21 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's bowler Lungi Ngidi, left, celebrates with teammate Temba Bavuma after dismissing England's batsman Jason Roy for 21 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's captain Eoin Morgan leaves the field after being dismissed by South Africa's bowler Beuran Hendricks for 9 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's captain Eoin Morgan leaves the field after being dismissed by South Africa's bowler Beuran Hendricks for 9 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood, center, celebrates with teammates after dismissing South Africa's batsman Lungi Ngidi for 11 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood, center, celebrates with teammates after dismissing South Africa's batsman Lungi Ngidi for 11 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's captain Quinton de Kock, right, plays a shot as England's wicketkeeper Jonny Bairstow watches on during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's captain Quinton de Kock, right, plays a shot as England's wicketkeeper Jonny Bairstow watches on during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood bowls during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood bowls during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

Moeen Ali saw England home with 17 not out from 16 balls in his first international in six months.

England's batsman Moeen Ali watches his shot to score a winning run during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's batsman Moeen Ali watches his shot to score a winning run during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England finished on 257-8 with nearly seven overs to spare for a victory that wasn't as comfortable as it should have been.

England also took a share of the series after South Africa won the first game and the second was abandoned because of rain.

Denly made his second half-century of the series and was once again the mainstay of the England innings at No. 5. He hit six fours and three sixes and followed on from opener Jonny Bairstow, who made 43, and Joe Root, who scored 49.

England's batsman Adil Rashid during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's batsman Adil Rashid during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's sub-par total was partly due to legspinner Adil Rashid, who was also recalled to the England team for his first appearance this tour.

He took 3-51, including the crucial wickets of South Africa captain Quinton de Kock for 69 and No. 3 Temba Bavuma for 29.

David Miller hit 69 not out for South Africa at the end of the innings but it wasn't enough.

A fan watches the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

A fan watches the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England captain Eoin Morgan won the toss and put South Africa in to bat, correctly deciding the pitch was best suited to chasing down a score.

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

South Africa's bowler Lungi Ngidi, right, celebrates the wicket of England's batsman Tom Curran for 5 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's bowler Lungi Ngidi, right, celebrates the wicket of England's batsman Tom Curran for 5 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's bowler Lungi Ngidi, left, celebrates with teammate Temba Bavuma after dismissing England's batsman Jason Roy for 21 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's bowler Lungi Ngidi, left, celebrates with teammate Temba Bavuma after dismissing England's batsman Jason Roy for 21 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's captain Eoin Morgan leaves the field after being dismissed by South Africa's bowler Beuran Hendricks for 9 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's captain Eoin Morgan leaves the field after being dismissed by South Africa's bowler Beuran Hendricks for 9 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood, center, celebrates with teammates after dismissing South Africa's batsman Lungi Ngidi for 11 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood, center, celebrates with teammates after dismissing South Africa's batsman Lungi Ngidi for 11 runs during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's captain Quinton de Kock, right, plays a shot as England's wicketkeeper Jonny Bairstow watches on during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

South Africa's captain Quinton de Kock, right, plays a shot as England's wicketkeeper Jonny Bairstow watches on during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood bowls during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)

England's bowler Saqib Mahmood bowls during the 3rd One Day International cricket match between South Africa and England at Wanderers stadium in Johannesburg, South Africa, Sunday, Feb. 9, 2020. (AP PhotoThemba Hadebe)