The Pakistani team Stops South Africa's 10-match Unbeaten Run.
The left-arm pacer took four wickets in the final innings following failing to take a wicket in the initial session.
Opening Test, the Gaddafi Stadium (day four)
Pakistan 378 (Imam-ul-Haq 93, Agha 93; Muthusamy 6-117) & 167 (Babar 42; Muthusamy 5-57)
South Africa 269 (De Zorzi 104; Noman 6-112) & 183 (Brevis 54; Shaheen 4-33, Noman 4-79)
Pakistan won by 93 runs
The national team halted the reigning champions South Africa's unbeaten run by sealing a 93-run margin win in an thrilling and closely contested first Test in Lahore.
The Proteas, who had a 10-Test unbeaten run in Test cricket culminated in victory over Australia in the WTC final in the month of June, were dismissed for 183 chasing 277.
Starting the day on 51 for two, they saw the dismissal of first-innings centurion Tony de Zorzi lbw to pace bowler Afridi to the third ball of the day to push the tightly balanced run chase in the home team's favor.
Slow left-armer Noman Ali, who took 10 wickets for 191 runs in the match, dismissed Tristan Stubbs for 2 and clean bowled Brevis, who put up a fight with a run-a-ball 54.
Right-arm spinner Sajid Khan also took advantage of significant spin to end opening batsman Ryan Rickelton's innings - he lasted 145 balls for 45 runs - and Afridi came back in the post-lunch session to knock over the lower order with a impressive exhibition of reverse-swing bowling.
He had Kyle Verreynne leg before for 19 and dismissed Subrayen and Rabada to seal the win.
It was both sides' opening game of the 2025-27 World Test Championship cycle and moves Pakistan straight into second place behind table-toppers Australia.
The win was built around key performances of 93 by opener Imam and, importantly, all-rounder Salman Agha which boosted them to 378.
From there slow bowlers Noman and Sajid took advantage of helpful home pitches, as they had in their Test series win over England last year, to maintain their advantage.
The next and final Test begins on October 20.