The Pakistani team Ends South Africa's 10-Test Winning Streak.
The left-arm pacer claimed four wickets in the second innings after failing to take a wicket in the initial session.
First Test, Lahore (the fourth day)
The home side 378 (Imam-ul-Haq 93, Salman Agha 93; Senuran Muthusamy 6-117) & 167 (Babar 42; Muthusamy 5-57)
South Africa 269 (Tony de Zorzi 104; Noman Ali 6-112) & 183 (Dewald Brevis 54; Shaheen Afridi 4-33, Noman 4-79)
Pakistan won by 93 runs
Pakistan terminated the reigning champions South Africa's unbeaten run by sealing a 93-run margin victory in an entertaining and competitive opening Test in Lahore.
The Proteas, whose 10-match winning streak in Test cricket culminated in victory over Australia in the World Test Championship final in the month of June, were bowled out for 183 in pursuit of 277.
Starting the day on 51-2, they lost century-maker De Zorzi lbw to pace bowler Afridi to the third ball of the day to shift the tightly balanced chase in the home team's favour.
Slow left-armer Noman Ali, who took 10-191 in the game, dismissed Tristan Stubbs for 2 and bowled Brevis, who put up a fight with a rapid 54.
Right-arm spinner Sajid Khan also capitalized on sharp turn to terminate opener Ryan Rickelton's innings - he faced 145 balls for 45 - and Shaheen came back in the post-lunch session to knock over the tail with a fine display of reverse swing.
He trapped 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 Test championship cycle and propels Pakistan straight into second place after leaders Australia.
The win was built around contributions of 93 by opening batsman Imam-ul-Haq and, crucially, number seven Agha which lifted them to three hundred and seventy-eight.
From there slow bowlers Noman and Sajid Khan utilized helpful home pitches, as they had in their series victory over the English team last year, to maintain their lead.
The second and final Test begins on October 20.