The aggressive batsman was unbeaten at lunch on 52 and with him Faf du Plessis was eight not out, both having added 21 for the unbroken seventh wicket stand.
South Africa, on 130-6, still need 63 runs to avoid an innings defeat in the first Test of the two-match series.
Pakistan's bowlers grabbed two wickets on the fourth morning to boost their chances on a Sheikh Zayed Stadium pitch offering good turn to their twin-spin attack led by Zulfiaqar Babar (2-16) and Saeed Ajmal (1-38).
Steyn had frustrated Pakistan in the first hour, playing defensively till the 12th over of the day when Babar introduced into the attack and with his first delivery bowled the nightwatchman.
More From This Section
Duminy, who hit 57 in South Africa's first innings of 249, could survive just five deliveries before he was trapped leg-before by Khan, leaving South Africa tottering at 109-6. Khan had figures of 2-32.
Pakistan could have removed du Plessis but wicket-keeper Adnan Akmal failed to catch a faint edge and missed the stumping as the batsman was out of his crease after playing the shot.
The second and final Test will be played in Dubai from October 23.