Pakistan leg spinner Danish Kaneria took five for 62 to help bowl Sri Lanka out for 233 on an action-packed second day of the third Test on Tuesday.
Kaneria, playing his first game of the series, bowled superbly to give Pakistan a 66-run first-innings lead.
The tourists lost opener Khurram Manzoor in the final over before stumps, bowled by left-arm spinner Rangana Herath, and finished on 16 for one, a lead of 82 runs.
Fawad Alam was unbeaten on 14 and Younus Khan on nought.
Tillakaratne Dilshan also scored a gutsy 44 batting with a fractured right index finger and Kumar Sangakkara made a fluent 45.
Sri Lanka, 2-0 up in the series, needed just 3.4 overs in the morning to end the Pakistan innings after the visitors had resumed on 289 for seven.
Left-arm paceman Thilan Thushara grabbed two of the last three wickets to fall, claiming career-best figures of five for 83.
Thushara wrapped up the innings as Pakistan's batting collapsed for the fourth time in the series, the last six wickets tumbling for 14 runs after the second new ball was taken.
GUL STRIKES
The Pakistan bowlers led the fightback after Umar Gul bowled Malinda Warnapura with the first ball of the innings and Khan bowled opener Tharanga Paranavitana for five to reduce Sri Lanka to 23 for two.
Sri Lanka would have been in deeper trouble had Manzoor not dropped Sangakkara on 16, spilling an easy catch at gully after the skipper played Mohammad Aamer away from his body.
Sangakkara stroked seven boundaries before he was adjudged lbw to spinner Saeed Ajmal to the last ball before lunch, although TV replays showed the ball pitched outside leg stump.
Ajmal struck another big blow after the interval with a sharp off break to bowl Thilan Samaraweera for six.
Jayawardene rallied the innings with Angelo Mathews, playing skilfully against quality spin bowling from Ajmal and Kaneria.
Kaneria made the breakthrough just before tea when he induced Mathews to edge a catch to slip.
Kaneria also dismissed Jayawardene with a cleverly disguised quicker ball and he trapped Chaminda Vaas lbw.
Dilshan launched a late assault, hitting two sixes and two fours in his 44 before being last man out.