Former champions India beat SA by one run but still crashed out of the T20 as Pakistan went through to the semifinals by virtue of a higher run rate.
India made 152-6 in their 20 overs and needed to restrict South Africa to 121 runs or less to reach the last four at Pakistan's expense. In the event they bowled their opponents out for 151 in a narrow but academic victory.
Pakistan will meet hosts Sri Lanka in the first semifinal in Colombo on Thursday while Australia, who went through on run rate despite losing to Pakistan, will play West Indies on Friday.
"Overall I am quite happy with how the team performed but there were instances where we should have had 10-15 runs more on the board. We lost too many wickets early in this match," said Indian captain Mahendra Singh Dhoni.
South African captain AB de Villiers said his team, who lost all three games in the Super Eights, "didn't click" and had let their country down.
"Disappointed isn't the word to describe it, we've had a poor tournament," said de Villiers. "We've let the country down and that's what hurts the most. We did all the preparation possible, we thought we were ready but the guys didn't click."
Faf du Plessis led the South African reply with an aggressive 65, studded with two towering sixes and six boundaries off just 38 balls.
When he fell in the 13th over with 58 runs were still needed but India's bowlers led by Zaheer Khan (3-22) kept their nerve to record their second win in three Super Eights encounters.
South Africa, who had lost both of their two earlier matches in the round of eight, needed 14 off the last Lakshmipathy Balaji over. Albie Morkel hit a six off the first ball but was bowled off the second.
Morne Morkel also hit a six off the fourth ball but Balaji snatched the win when he bowled the last man with a full-length delivery, ending on figures of 3-37.
India owed their total of 152-6 to Suresh Raina's 45. Raina hit five boundaries during his 34-ball knock and added 44 for the fifth wicket with Rohit Sharma, who made 25.
India were off to a disastrous start as opener Gautum Gambhir was bowled by Morne Morkel in the fourth over for eight, before the in-form Virat Kohli was caught behind off a rising delivery from Jacques Kallis for two in the next.
It became 36-3 when Peterson bowled Virender Sehwag for 17, after the Indian opener hit him for a big six a ball earlier. Dhoni chipped in with a quick 13-ball 23 with three boundaries.
Morkel finished with 2-28 while Peterson took 2-25.
Australia reached the World Twenty20 semifinals despite a 32-run loss to Pakistan in the Super Eights.
Pakistan scored 149-6 off its 20 overs but Australia gave up chasing the win after feared openers Shane Watson and David Warner were dismissed for 8 each.
Instead, Australia went after the 112 runs it needed to seal a place in the last four, and finally got there when Mike Hussey hit a boundary off fast bowler Umar Gul to start the last over.
Australia ended up on 117-7, suffering its first loss in the tournament. Pakistan's semifinal fate was decided in the last Super Eights match, ultimately going through when India failed to convincingly beat already-eliminated South Africa. India won by one run but was knocked out of the tournament because of an inferior run-rate.
"Pakistan completely outplayed us," Australia captain George Bailey said, "but it's a three-phase tournament and we're in phase three [semifinals].
"To this point we've been really consistent and the challenge will be to get that form back in the semifinals."
Pakistan opened its bowling with spinners and continued to attack with spin for 18 overs with their premier seamer Gul getting just two.
"I don't think it's any great secret that we have some deficiencies at times against spin and that probably showed tonight," Bailey said.
"Tactically very astute game from them to bowl spin till the 18th over, I don't know if that's happened in any Twenty20 game before."
Left-armer Raza Hassan gave the in-form Watson his first single-digit score in the tournament with the total on 15. Watson has been in imperious form with three half centuries and an unbeaten 41.
Hafeez entered the fray with his offspin and dismissed Warner lbw to reduce Australia to 19-2 after five overs.
Australia could not recover as the spinners made them work hard for runs. With Watson and Warner virtually winning matches with the bat for Australia, its unexposed middle and low order faltered under pressure.
"It's a great effort by the bowlers. We got the total we wanted today, and then I think spinners did a great job," said Pakistan captain Mohammad Hafeez.
Hussey made a determined 54 not out off 47 deliveries including a six and four boundaries on a slow R Premadasa Stadium pitch that did not favour stroke play.
Hasan finished with a career best 2-14 off his four overs, surpassing his previous best of 2-15 also against Australia before this tournament. Offspin bowler Saeed Ajmal returned the best bowling figures with 3-17 while Hafeez also took two wickets.
Hasan was named player of the match for providing an impressive start.
Earlier, Pakistan's Nasir Jamshed made 55 off 46 deliveries and shared 79 runs with Kamran Akmal for the third wicket to lift Pakistan to a decent score after being 29-2. Jamshed hit two sixes and four boundaries while Akmal scored 32 runs. Australia's left-arm seamer Mitchell Starc took 3-20. – Sapa-AFP