Left-arm pace bowler Mohammad Aamer claimed three wickets in an outstanding post-lunch spell to leave Pakistan chasing just 168 for victory in the opening Test against Sri Lanka on Monday.
Pakistan bowled out the hosts for 217 and then finished the third day on 71 for two -- just 97 runs shy of their victory target having lost the wickets of Khurram Manzoor (15) and Younis Khan (3).
Opener Salman Butt was unbeaten on 28 with first-innings centurion Mohammad Yousuf on 12 with the tourists closing in on a 1-0 lead in the three-match series.
The 17-year-old Aamer followed up on his impressive first innings performance (3-74) by capturing the key wickets of Tharanga Paranavitana (49), Mahela Jayawardene (0) and Kumar Sangakkara (14) as the tourists took control.
Aamer went wicketless during a rain-shortened morning session but swung the ball both ways in the afternoon to reduce Sri Lanka to 101-5 after they had appeared comfortable on 86-2.
The debut-making teenager finished with figures of 3-38 from 11 overs and a match haul of six for 112.
In the morning after a delayed start, opener Malinda Warnapura lasted just two balls in the morning before edging an Umar Gul delivery to slip.
However, Paranavitana steadied the innings in partnership with Rangana Herath, the pair adding 68 for the second wicket.
Paranavitana, Sri Lanka's first-innings top scorer, had batted beautifully for his 49 from 58 deliveries with five boundaries before edging a quick outswinger to wicketkeeper Kamran Akmal.
Former skipper Jayawardene, who averages over 80 at this seaside venue, was also caught behind off a delivery that nipped off the seam towards the slips.
Captain Sangakkara pushed loosely at another outswinger and Akmal completed a fine diving catch in front of first slip.
Younus Khan also chipped in with vital wickets with his medium pace, first trapping nightwatchman Herath (15) in the morning and then dismissing the in-form Tillakaratne Dilshan (22), who steered a full-length delivery to gully.
Off-spinner Saeed Ajmal struck in the final half-hour of the afternoon session as the well-set Thilan Samaraweera, who had stroked 34 from 67 balls, was caught at slip off his doosra.
Ajmal also polished off the tail, trapping Nuwan Kulasekara lbw for 25 and bowling last-man Ajantha Mendis for one to finish with three for 34 from 12.2 overs.
Pakistan's openers made a steady start with a 36-run stand before Mendis had Manzoor caught at slip immediately after a drinks break and ball change.
Next over Mathews pinned Khan lbw with a delivery that seamed-back sharply to leave Pakistan 39 for two.
Yousuf and Butt negotiated the final tense overs to leave Pakistan with an excellent chance of winning on Tuesday.
Scorecard
Sri Lanka (1st innings): 292 (T. Paranavitana 72)
Pakistan (1st innings): 342 (Mohammad Yousuf 112)
Sri Lanka (2nd innings): (overnight 0-0)
R. Herath lbw Khan 15
M. Warnapura c Khan b Gul 0
T. Paranavitana c Akmal b Aamer 49
K. Sangakkara c Akmal b Aamer 14
M. Jayawardene c Akmal b Aamer 0
T. Samaraweera c Misbah b Ajmal 34
T. Dilshan c Mansoor b Khan 22
A. Mathews c Butt b Rauf 27
N. Kulasekara lbw Ajmal 25
T. Thushara not out 15
A. Mendis b Ajmal 1
Extras: (7-lb, 1-w, 7-nb) 15
Total: (in 56.2 overs) 217
Fall of wickets: 1-0, 2-68, 3-86, 4-88, 5-101, 6-138, 7-156, 8-191, 9-211, 10-217
Bowling: Aamer 11-2-38-3, Gul 10-2-62-1 (6-nb, 1-w), Rauf 13-1-49-1, Khan 10-1-27-2 (1-nb), Ajmal 12.2-0-34-3
Pakistan (2nd innings):
K. Manzoor c Jayawardene b Mendis 15
S. Butt not out 28
Y. Khan lbw Mathews 3
M. Yousuf not out 12
Extras: (12-b, 1-w) 13
Total: (for two wickets, 19 overs) 71
Fall of wickets: 1-36, 2-39
Bowling: Kulasekara 5-1-14-0, Thushara 4-0-9-0 (1-w), Mathews 4-0-13-1, Mendis 5-0-17-1, Herath 1-0-6-0.