Young all-rounder Thisara Perera followed his four wickets with 75 off 86 balls as Sri Lanka seized control of the final Test against Pakistan in Pallekele on Tuesday.
Pakistan, seeking a series-levelling win, paid for sloppy fielding as Sri Lanka recovered from a middle-order collapse to make 337 in their first innings on the third day.
The tourists, trailing by 111 runs, were 27-1 in their second knock by stumps, losing opener Taufeeq Umar for four, leg-before to seamer Nuwan Kulasekara. (Scorecard)
Mohammad Hafeez was unbeaten on eight and Azhar Ali was on six, with Pakistan trailing by 84 runs with nine wickets in hand.
The resolute batting by the hosts has given them a chance to build on the 1-0 series lead. Sri Lanka won the first Test by 209 runs before the second was drawn. (Stats from the day)
Sri Lanka were only 10 runs ahead when they lost their seventh wicket, but Perera and Kulasekara (33) snatched the initiative by adding 84 for the eighth.
Perera, a 23-year-old from Colombo playing only his sixth Test, smashed four fours and three sixes in his maiden half-century after being dropped twice on 11 and 22.
Seamer Umar Gul first missed a return catch and then saw skipper Misbah-ul Haq spill a low chance in the slips off his own bowling.
Perera, whose four wickets in the first innings engineered Pakistan's collapse for 226, was last man out when he was bowled by left-arm seamer Junaid Khan.
Junaid finished with 5-70, his second successive five-wicket haul, while off-spinner Saeed Ajmal claimed 3-66.
The third day's play provided a keen tussle between bat and ball, compensating for the entire second day being lost due to rain.
Tharanga Paranavitana and Thilan Samaraweera led Sri Lanka's charge with a fourth-wicket stand of 143 after surviving a testing morning session in overcast conditions.
The pair had come together when skipper Mahela Jayawardene fell off the last ball of the first day's play to leave Sri Lanka tottering at 44-3 at stumps.
Left-handed Paranavitana scored 75, his highest score in the series, and Samaraweera made 73 in a timely return to form after aggregating just 21 runs in the previous two Tests.
Pakistan bounced back in the post-lunch session as Ajmal grabbed two quick wickets to leave Sri Lanka on 204-6 after they were comfortably placed at 187-3.
Samaraweera was lucky to get to a half-century as Younis Khan floored a shoulder-high catch off Gul when the batsman was on 49.
The fourth-wicket stand was broken midway through the afternoon session when Samaraweera played back to Ajmal and was out leg-before.
New man Angelo Mathews began with a promising on-drive off Mohammad Sami for four, but fell for nine when he sliced Junaid to Asad Shafiq at gully.
Paranavita's five-hour vigil ended soon after, bowled by Ajmal to make Sri Lanka 204-6, still 23 runs away from gaining the lead.
Pakistan felt the absence of wicket-keeper Adnan Akmal, who was confined to the dressing room with a hairline fracture in his left hand sustained while batting on the opening day.
Umar, who kept wickets, conceded 16 byes.