After South Africa comfortably won the First Test in Johannesburg by 211 runs, Pakistan hit back well over the first three days in Newlands to come into Day 4 looking to set the Proteas a big run chase in the fourth innings of the match.
Pakistan had a 12-run lead on the first innings thanks to a pair of 111's from Younis Khan and Asad Shafiq, and then steadied in their second innings after being 2-7 to be 3-100 at stumps on Day 3.
Captain Misbah-ul-Haq didn’t last long Sunday, though, falling for 44 when caught by Graeme Smith off Robin Peterson.
Azhar Ali then teamed up with Shafiq to put on 33 for the fifth wicket before Shafiq was out for 19 when bowled by Vernon Philander.
That sparked a dramatic collapse once again from Pakistan as the tourists lost their last six wickets for just 22 runs as Philander, Peterson and Dale Steyn ripped through the lower order.
Ali top-scored with 65, but after being in such a strong position Pakistan was bowled out for 169 to set South Africa just 182 to win the match, and take an unbeatable 2-0 lead in the three-match series.
Philander took 4-40 for South Africa with Steyn picking up 3-38 and Peterson 3-73 to back up his crucial knock of 84 with the bat.
South Africa's run chase got off to a horror start with Alviro Petersen gone in the fourth over for just one, but the Proteas steadied from there to never really be threatened of not getting the required runs despite more brilliant bowling from off-spinner Saeed Ajmal.
Smith made 29, Hashim Amla 58, Jacques Kallis 21, AB de Villiers 21 and Faf du Plessis 15 with Dean Elgar remaining not out on 11 and Peterson one as South Africa made 6-182 to win the Test by four wickets.
Ajmal was again the star with the ball for Pakistan taking 4-51 from 18.1 overs backing up his 6-96 from 42 overs in the first innings to give him outstanding match figures of 10-147 from 60.1 overs.
The win continues to confirm South Africa as the far and away best nation in the world with the Proteas now having gone 14 Tests in-a-row without a loss, not having lost in the last 12 series' and has six series wins on the trot. All are South African records.
Smith was delighted with his team's effort to still find a way to win on a pitch at Newlands tailor-made for Ajmal.
"It was a tough Test and I think Pakistan played really well with the conditions suiting them a lot more. It reminded me a lot more of a sub-continent type wicket and they looked at home on those conditions," Smith said.
"We were under pressure on Day 1 and 2, and on Day 3 and 4 we really stepped it up and played some outstanding cricket. It was just really encouraging to see the way we played and fought, and to come away with the victory is such a good feeling."
Misbah was disappointed to lose after being in a good position in the game, but was at least pleased with the improved performance and hopes that continues now at Centurion in the third and final Test.
"It was a pretty improved performance especially from the batting in the first innings with the way Shafiq and Younis scored hundreds. I think that was really pleasing and that brought us into the game," Misbah said.
"But really after we got their first five wickets, Peterson's innings took the advantage from us. Then today we had a batting collapse again.
"If we could have even set a 250 target that could have been really tricky on this wicket, but we had another batting collapse and that was really disappointing. Especially on a wicket that was behaving well and it wasn’t that you couldn’t play on it.
"The series is gone, but every Test match is really important for us especially against the top quality side in the world. The performance of every game is important and even though we have lost the series, we have to come hard and put in a better show in the next game."