(CNN) -- England booked their place in the semifinals of Champions Trophy with a thrilling 22-run victory over hosts South Africa at Centurion Park on Sunday night.
Owais Shah scored a superb 98 in England's imposing total of 323.
South Africa, led by captain Graeme Smith, made a brave effort of chasing 324 for victory in the Group B match, but could not keep up with the required rate in under the floodlights and are out of the tournament after two defeats in three games.
Smith, battling cramp but denied the use of a runner by England captain Andrew Strauss, was the ninth man out for 141 off 134 balls to signal the end of the home side's challenge.
He was dropped by Owais Shah off Paul Collingwood before he reached his century, but almost single handedly kept his team in the hunt.
Shah eventually ended his innings as he clung on to a steepler off the bowling of the expensive Stuart Broad (3-67).
James Anderson led the England bowling with an inspired tally of three for 42 in his 10 overs on a flat batting wicket.
England owed their big total to a third wicket stand of 163 between Shah and Paul Collingwood in just 26.1 overs.
Shah was dismissed two short of a deserved century off 89 balls while Collingwood supported with a solid 82.
Their stand set up a late onslaught of 92 in the last 10 overs, led by Eoin Morgan with 67 off 34 balls with five sixes to total 323 for eight.
Morgan also performed heroically with the wicketkeeping gloves as a late replacement for the ailing specialist Matt Prior.
It was also England's highest one-day total against South Africa, the previous best being 304 for eight.
In other Group B action on Sunday, New Zealand beat Sri Lanka by 38 runs to boost their chances of reaching the semifinals.
They will be guaranteed a last four place with victory against England in the final group match on Tuesday.
A little of the gloss was taken off their victory as opening batsman Jesse Ryder was ruled out of the rest of the tournament with a hamstring injury and also fined by the ICC for smashing a chair with his bat after he walked off the field.
He made a quickfire 74 in New Zealand's 315 for seven in 50 overs, but his absence, combined with the loss of bowler Jacob Oram to injury could prove costly.
Ryder top-scored in the innings with Martin Guptill (66), skipper Daniel Vettori (48) and Brendon McCullum (46) also making fine contributions.
Sri Lanka were always struggling against accurate Kiwi bowling with Daryl Tuffey taking two for 39 and Kyle Mills three for 69.
Mahela Jayawardene made 77 off 85 balls, but when he was out in the 39th over with the score 219 for seven, the game was all but lost.