(CNN) -- New Zealand will face either Sri Lanka or England in the semifinals of the Cricket World Cup after stunning South Africa by 49 runs in Dhaka on Thursday.
South Africa came into the match as strong favorites to reach the last four but, in reply to New Zealand's modest-looking total of 221-8 from their 50 overs, they crumbled to 172 all out after looking in control on 108-2.
Jacob Oram took four wickets for the Black Caps, as well as two catches, while off-spinner Nathan McCullum claimed three victims as South Africa maintained their dismal World Cup record.
The Proteas have never before reached a World Cup final and have now lost three semifinals and two quarterfinals while, in contrast, It will be New Zealand's sixth appearance in the semifinals.
New Zealand's total was helped by left-hander Jesse Ryder, who finally struck form with a superb knock of 83 -- after only reaching a best score of 38 in his previous six innings.
However, South Africa looked to be cruising to their victory target of 223 -- captain Graeme Smith (28) and Jacques Kallis (47) putting on 61 for the third wicket, before a spectacular collapse saw them lose their last eight wickets for just 64 runs.
Speaking immediately after the match, New Zealand captain Daniel Vettori said: "Every single bowler stepped up and probably it was the fielding that got us through.
"Once we got 220, we knew we had to be aggressive. We knew it was a tricky wicket and it was going to be an old-school one-day game."
Meanwhile, a despondent Smith said: "There are no words to describe how I feel -- we just have to take it on the chin.
"It was a very disappointing evening. I thought we bowled pretty well and at 100 for 2, we were sitting well, and then we lost too many wickets," he added.