Quinton de Kock hit 68, including eight fours, and Hashim Amla was 41 not out in South Africa's 131-1 in 28.4 overs in reply to Afghanistan's 125 all out in 34.1 overs. Because of two rain disruptions, the match was reduced to 48 overs per team with South Africa chasing a winning target of 127.
Andile Phehlukwayo (17 not out) sealed victory by smashing the only six of the game. Amla was cautious but effective in his 83-ball knock which took him to within 24 of the 8,000 ODI runs milestone. De Kock's innings lasted 72 balls and he shared an opening partnership of 104 with Amla before he was caught by Mohammad Nabi off the bowling of Gulbadin Naib in the 23rd over. It was South Africa's first century stand of the tournament.
After defeats to England, Bangladesh and India, and a washout against West Indies, this was a must-win game for four-time semifinalist South Africa. But it still looks unlikely to advance to the final four. South Africa is level on three points in the bottom half of the table with West Indies, Bangladesh and Pakistan but has played one more game.
Afghanistan has lost all four matches and remains last in the 10-team standings.
Australia moved to the top of the Cricket World Cup standings after beating Sri Lanka by 87 runs at the Oval.
Captain Aaron Finch lost the toss again and was made to bat first, but he spearheaded Australia's effort with a career-best 153 in a total of 334-7.
Counterpart Dimuth Karunaratne tried to inspire his side the same way, but after he was out for a career-best 97 in the 33rd over, Sri Lanka collapsed. From 186-2 to 247 all out, the last eight wickets fell for 61 runs.
Mitchell Starc took 4-55, Kane Richardson 3-47, Pat Cummins 2-38 and Jason Behrendorff, making his World Cup debut in place of Nathan Coulter-Nile whose back stiffened up, took a wicket.
Australia's fourth win from five matches lifted it above New Zealand and England to lead the tournament halfway through its group stage matches.
Sri Lanka, which hadn't played in 11 days after two washouts, has only one win from five matches but remains fifth overall.
South Africa needs 127 runs to beat Afghanistan and claim its first win at the Cricket World Cup.
Afghanistan was all out for 125 in 34.1 overs at Sophia Gardens in Cardiff after collapsing from 69-2. Two rain breaks reduced the game to 48 overs with the DLS method slightly adjusting the winning target for the South Africans.
The 40-year-old spinner Imran Tahir did most of the damage for South Africa, finishing with 4-29 off seven overs. Seamer Chris Morris was even meaner, taking 3-13 in 6.1 overs.
The Afghans had hoped to use all their batting overs for the first time this tournament and in their first-ever ODI against South Africa.
Before the second break for rain, Afghanistan appeared on the brink of building a reasonable score. Afterward, it collapsed to 77-7 off 25.2 overs before staging a mini-recovery as Ikram Ali Khil and Rashid Khan shared a 34-run partnership for the eighth wicket.
Rashid top-scored with 35 off 25 balls, including six boundaries, followed by Noor Ali Zadran's 32 runs off 58. Both men fell to Tahir.
Afghanistan has collapsed against South Africa, losing four wickets in 10 balls for a single run at one stage, as it stumbled to 77-7 off 25.2 overs.
South Africa spinner Imran Tahir took a wicket with his first ball, and claimed a second in the same over, after a rain break for the Afghans at Cardiff's Sophia Gardens.
Play had resumed in the Welsh capital following an hour's disruption with the game reduced to 48 overs per team, though Afghanistan is once again unlikely to use all its allotted overs.
Afghanistan resumed on 69-2 off 20 overs and Hashmatullah Shahidi was caught in the slips by Faf du Plessis off Andile Phehlukwayo in the first over back.
Then Tahir came on to bowl Noor Ali Zadran for 32 and caught-and-bowled former captain Asghar Afghan for a five-ball duck.
That made it 70-5 before Phehlukwayo bowled Mohammad Nabi, and Tahir dismissed Gulbadin Naib as Afghanistan self-destructed.
There's a big demand for tickets for the India-Pakistan Cricket World Cup contest in Manchester.
How big? The Old Trafford venue will seat 23,500 for Sunday's game, including the temporary Stand D.
Pakistan coach Mickey Arthur was told during his pre-match news conference the venue could have been sold 20-times over, and 500,000 people wanted to be at the game. The BBC has reported there were 700,000 ticket applications.
Both countries have vast populations, there are large numbers of ex-pat Indian and Pakistani people living in the region, and cricket is by far and away the No. 1 sport in the subcontinent. There may be a little bit of license about demand for tickets amid all the hype over the contest, but there's no doubt it will be jam packed and fan zones around the city will be full.
Arthur, a South African who has coached the national teams of South Africa, Australia and now Pakistan, has urged his players to make the most of the occasion.
"It's the — well, I don't want to say it's the biggest rivalry in sport, but I saw some stats, you know, which said I think the soccer World Cup final attracted 1.6 billion viewers. Tomorrow, likely to get 1.5 billion," he said. "It doesn't get bigger than that. It doesn't get more exciting.
"I'm telling our players in the dressing room, you could be a hero tomorrow. Your careers are going to be defined by a moment in the game. You do something incredible tomorrow, you'll be remembered forever."
India has won all six of the Cricket World Cup games between the countries.
Afghanistan is taking it slow but steady in its quest to bat for all its allotted overs in the Cricket World Cup.
The lowest-ranked team in the 10-team tournament reached 69-2 from 20 overs against South Africa before rain interrupted play for the second time in the day-night match in Cardiff.
Afghanistan has so far failed to use up its batting overs in all three games, reaching 207 in 38.2 overs against Australia, 152 in 32.4 versus Sri Lanka and 172 in 41.1 against New Zealand. It lost all three games.
South Africa won the toss and made Afghanistan bat. The first rain interruption, a 26-minute delay, disturbed a promising start by Afghanistan on 33-0 off 5.5 overs.
Opener Hazratullah Zazai pulled a delivery from pacer Kagiso Rabada and was caught by Rassie van der Dussen running in from the boundary for 22 off 23 balls. Rahmat Shah was the other Afghan batsman out, leg before wicket to an impressive Chris Morris for a 22-ball 6.
Noor Ali Zadran is 32 not out off 57 balls and Hashmatullah Shahidi has scored a leisurely 18-ball 8.
Virat Kohli has played Pakistan a dozen times, and the first remains his most tense against the archrivals.
On the eve of the World Cup group game in Manchester, the India captain was asked to recall his most tension-filled and funniest moments against Pakistan.
The first one was easy, Kohli said, because he thought it may have been his last innings for India. The second would take too much explaining, he said, suffice to say it involved Shahid Afridi and Wahab Riaz in the 2011 World Cup semifinal at Mohali.
"Tense was Champions Trophy 2009 ... I was literally flown in and in two days' time I was playing against Pakistan at Centurion," South Africa, he said. "I hadn't experienced anything like that before, and I played a very bad shot, and I couldn't sleep until six in the morning.
"I was looking at the ceiling and thinking, that's it, I've flown in, and now I'm finished."
Kohli was out for 16, third wicket down, as India chased 303. He advanced down the wicket to legspinner Afridi and hit to long-off, where Umar Gul took a juggling, three-swipe catch to complete the dismissal. Pakistan won the game convincingly.
Kohli had played only six ODIs until then — all against Sri Lanka — and it was good thing India gave him another chance. He scored an unbeaten 79 in his next innings against West Indies at the tournament and has gone on to play a further 221 one-day internationals, win a World Cup and become India captain.
As for the funniest, Kohli would only say it involved a conversation between Afridi, who was captain that day, and Wahab, who took five wickets for Pakistan.
"There was a little incident which I saw from the opposition side, which I can't really elaborate here ... that was quite funny," he said, laughing. "I was standing at the strikers, and I heard a conversation, which as I say, I can't elaborate here, but in a high pressure game, that made me laugh, that's all I can say."
The local bowler who spent four nights in a London hospital after being hit by a David Warner drive in the practice nets last week has had a reunion with the Australian batsman and his teammates at the Oval.
Jaykishan Plaha was bowling to Warner ahead of Australia's Cricket World Cup group game against India when he was struck on the head, treated at the scene and then taken to a nearby hospital by ambulance.
Medical tests cleared Plaha of injury, and was released in time to meet up with the Australians back at the Oval before the defending champions played Sri Lanka.
"To come in and roll the arm over and unfortunately get hit was sad, it was a real shock to us," Warner said in an interview with the host broadcaster. "Now he's recovering, back on his feet and said he'll be bowling again in about six weeks."
Warner presented Plaha with a signed shirt, and said the young bowler would attend Australia's game against top-ranked England at Lord's on June 25 as well.
Aaron Finch hit a career-best 153 in spearheading Australia to 334-7 against Sri Lanka at the Oval.
Australia's third consecutive 300-plus total and biggest yet of this campaign was powered by the captain's 14th one-day international hundred in a partnership of 173 with Steve Smith, who made 73.
After Finch and Smith were out in the 43rd and 44th overs, Glenn Maxwell plundered 46 from 25 balls but, as against Pakistan, Australia wasted wickets in hand at the end by losing three wickets in the space of 10 balls.
Still, Sri Lanka was left with a daunting chase in its first match in 11 days after two washouts.
Isuru Udana, the fast-bowling allrounder, starred with the wicket of Finch and Shaun Marsh, two run outs, and a catch. And this was after he hurt his left shoulder from sliding into the advertising boards in the fourth over.
South Africa won the toss and chose to bowl against Afghanistan on a green-tinged pitch in mostly sunny conditions at Sophia Gardens.
Four-time Cricket World Cup semifinalist South Africa kept an unchanged lineup from its washout against West Indies. Proteas fast bowler Lungi Ngidi is given more time to recover from a hamstring injury.
Afghanistan made one change from its seven-wicket defeat to New Zealand, bringing in former captain Asghar Afghan and dropping batsman Najibullah Zadran.
It's the first time South Africa and Afghanistan have faced each other in ODI history but the two teams have a lot in common ahead of the day-night match.
Both have lost three times already in this tournament and occupy the last two places in the 10-team standings. Both camps have been unsettled by controversies over team selection.
South Africa: Hashim Amla, Quinton de Kock, Aiden Markram, Faf du Plessis, Rassie van der Dussen, David Miller, Andile Phehlukwayo, Chris Morris, Kagiso Rabada, Beuran Hendricks, Imran Tahir
Afghanistan: Hazrat Zazai, Noor Ali Zadran, Rahmat Shah, Hashmatullah Shahidi, Asghar Afghan, Mohammad Nabi, Gulbadin Naib, Ikram Ali Khil, Rashid Khan, Aftab Alam, Hamid Hassan
Australia captain and opener Aaron Finch has reached a century off 97 balls against Sri Lanka at the Oval.
Finch hit left-arm spinner Milinda Siriwardana over the long on fence in the 33rd over to bring up his 14th one-day international ton, and third this year.
The fourth six of his innings followed nine boundaries.
He survived an lbw video review in the 12th on the umpire's not out call, and has otherwise played a brilliant innings that has been signaled over the last two weeks. He scored 66 against Afghanistan, and 82 against Pakistan on Wednesday.
Australia was 110-2 against Sri Lanka after 25 overs, with captain Aaron Finch on 67 from 75 balls, and Steve Smith with him on 2.
Finch lost another toss — he's yet to win one in five matches — and was made to bat at the Oval. He and David Warner were untroubled in reaching their fourth half-century opening partnership of this tournament.
Warner, off to another slow start to make a late charge, was out for 26 off 48 balls at 80-1 when Dhanajaya de Silva bowled his middle stump. Warner was trying to cut a skidding ball that came at him straighter than expected.
Usman Khawaja then departed for 10, caught on the midwicket boundary sweeping at de Silva.
Smith joined Finch, who brought his 50 up off 50 balls, his third half-century at this World Cup.
West Indies allrounder Carlos Brathwaite has received a reprimand and one demerit point for showing dissent to the umpires in the loss to England on Friday at Southampton.
Brathwaite made his displeasure clear when he was given out caught behind while batting on 14 from 22 balls in the 44th over.
He admitted to the offence and accepted the sanction from match referee David Boon.
Sri Lanka won the toss and chose to bowl first against Australia on a fresh pitch at the Oval in dry conditions.
Sri Lanka fast bowler Nuwan Pradeep, who dislocated and cut a finger on his right bowling hand in practice, passed bowling and catching tests and will play.
Sri Lanka made one change from its last match 11 days ago, dropping fast bowler Suranga Lakmal, who hasn't taken any wickets in two World Cup matches, for left-arm spin bowling allrounder Milinda Siriwardana, who will play his first one-day international since October 2017.
Australia also made one change: Fast bowler Nathan Coulter-Nile was "stiff," captain Aaron Finch said, and replaced by Jason Behrendorff, playing his seventh ODI.
Sri Lanka: Dimuth Karunaratne (captain), Lahiru Thirimanne, Kusal Perera, Kusal Mendis, Angelo Mathews, Dhananjaya de Silva, Thisara Perera, Isuru Udana, Milinda Siriwardana, Nuwan Pradeep, Lasith Malinga.
Australia: Aaron Finch (captain), David Warner, Usman Khawaja, Steve Smith, Shaun Marsh, Glenn Maxwell, Alex Carey, Pat Cummins, Mitchell Starc, Jason Behrendorff, Kane Richardson.
Sri Lanka and Australia meet in a one-day international for the first time in three years in the Cricket World Cup on Saturday.
Meanwhile, South Africa and Afghanistan face each other for the first time in ODI history, in Cardiff.
A fresh pitch and dry conditions await Sri Lanka and Australia at the Oval.
The group match will be Sri Lanka's first in 11 days after two abandonments because of rain in Bristol.
While Sri Lanka was restricted to training indoors, Australia played three matches in the meantime, and can go top of the standings with a fourth win from five matches.
In World Cup history, Australia leads these matchups 7-2.
Sri Lanka paceman Lasith Malinga needs four more wickets to become the fourth bowler to reach 50 in World Cup history, after Glenn McGrath (71), Muttiah Muralitharan (68), and Wasim Akram (55).
South Africa has three losses and a no result from its first four matches.
Afghanistan is on a losing streak, too, having lost three straight ODIs for the first time since the 2015 World Cup.
South Africa's Imran Tahir is the only spinner at this World Cup to have bowled 100-plus overs and not been hit for a six.
Hashmatullah Shahidi needs 54 more runs to reach 1,000 in ODIs, and become the ninth Afghan batsman to the milestone. He scored 59 in his last match against New Zealand.
Rain in Cardiff in the morning is set to clear in the afternoon with the chance of occasional showers. The day-night match starts 1230 GMT.
More AP cricket: www.apnews.com/cricket and https://twitter.com/AP_Sports