Durban: Sri Lanka were bowled out for 191 and were unable to build on a good first day when their inexperienced bowlers surprised the South African batsmen, who could manage only 235 in their first innings.
Steyn and Vernon Philander soon put their stamp on the game when Sri Lanka resumed at 49 for one on Thursday, taking three wickets in the first ten overs of the morning.
Kusal Perera played some bold and occasionally lucky strokes in making 51 off 63 balls for Sri Lanka and the hosts were frustrated when a barrage of short-pitched bowling could not break a stubborn ninth wicket partnership of 32, the joint second-highest of the innings, between debutant Lasith Embuldeniya and Kasun Rajitha.
It was particularly frustrating for Steyn, who bowled unchanged for a ten-over spell after lunch in a bid to claim the 27th five-wicket haul of his Test career.
He had already taken four wickets when Rajitha, on ten, gloved what looked a simple chance to Dean Elgar in the gully, only for the fielder to put it down.
The stand was eventually ended by a smart run-out of Rajitha by Aiden Markram at short leg.
Steyn took his career tally to 437 Test wickets, passing India’s Kapil Dev (434) and drawing level with Stuart Broad of England in joint seventh place on the all-time list.
With bright sunshine following the morning’s overcast conditions, the stage seemed set for South Africa to move into a commanding position as Markram struck the ball crisply in making 28 off 31 balls in an opening partnership of 36 with Elgar.
But Markram played one attacking shot too many when an attempted back foot force off Rajitha flew to Kusal Mendis at second slip.
Three more wickets fell reasonably cheaply as South Africa’s top-order batting again proved fragile.
Hashim Amla edged Vishwa Fernando to gully before Embuldeniya followed up his courageous innings of 24 off 63 balls by dismissing Temba Bavuma grabs advantage for south Africa and Elgar with his left-arm spin bowling.
Bavuma was leg before wicket for three when he missed a sweep and Elgar fell for 35 to a superb return catch when he skipped down the wicket and hit the ball hard but close enough for the bowler to take a reflex catch to his left.
Find latest and upcoming tech gadgets online on Tech2 Gadgets. Get technology news, gadgets reviews & ratings. Popular gadgets including laptop, tablet and mobile specifications, features, prices, comparison.
Fakhar hit 193 off 155 balls with 10 sixes and 18 fours but he lacked support as Pakistan made 324 for nine in reply to South Africa's 341 for six.
Rizwan made an unbeaten 74 as Pakistan chased down a target of 189 with one ball to spare. Their previous highest T20 chase was 188 against Australia in Harare in 2018.
Follow live scorecard and updates from the 2nd ODI between Pakistan and South Africa on our blog.