Skipper Dimuth Karunaratne battled through back pain to extend Sri Lanka's second-innings lead to 323 after key strikes by Pakistan's bowlers in the second Test on Tuesday.
The hosts reached 176-5 when bad light stopped play early on day three, with stumps called in Galle after more than half an hour's wait for conditions to improve.
The left-handed Karunaratne, on 27, and Dhananjaya de Silva, on 30, were batting in an unbeaten stand of 59.
Spinner Ramesh Mendis had claimed a five-wicket haul to help bowl out tourists Pakistan for 231 in the opening session, with the hosts at a lead of 147 going into their second innings.
Sri Lanka were in trouble at 117-5 when Karunaratne, who stayed off the field during Pakistan's innings, and De Silva got down to the grind.
De Silva took on the opposition bowlers and hit six boundaries with Karunaratne happy to play anchor. The skipper got help from the physio in between his knock.
Karunaratne rotated the strike and also hit two boundaries including a reverse sweep for four off leg-spinner Yasir Shah.
Pakistan earlier rattled the Sri Lankan batting with key wickets including Angelo Mathews in his 100th Test after the former captain, who made 35, attempted to rebuild the innings with Dinesh Chandimal.
Off-spinner Agha Salman got Mathews out for his maiden Test wicket after Pakistan reviewed the umpire's call, with ultra-edge technology confirming a spike when the ball passed the bat and into the hands of slip.
The in-form Chandimal, with scores of 206 not out, 76, 94 not out and 80 in his last four innings, looked good on 21 but fell caught behind off fast bowler Naseem Shah soon after tea.
Naseem, who took three wickets in Sri Lanka's first innings, had struck first with the wicket of Niroshan Dickwella, who fell for 15 after opening in place of the ailing Karunaratne.
Yasir sent back Oshada Fernando for 19 and fellow spinner Mohammad Nawaz trapped Kusal Mendis lbw for 15.
Pakistan's innings ended after the tourists resumed the day on 191-7, in reply to Sri Lanka's first innings of 378.
Off-spinner Ramesh sent back Nauman Ali and then trapped overnight batsman Yasir lbw for 26 to record a third five-wicket haul in his 10th Test to wrap up the innings.
Pakistan lead the two-match series 1-0 and Sri Lanka are looking to draw level on a pitch which has favoured the batsmen but is expected to turn come day four.
The tourists chased down a record 342 at the same venue in the opener.
Sri Lanka v Pakistan second Test scoreboard
Scoreboard at stumps on day three of the second Test between Sri Lanka and Pakistan in Galle on Tuesday:
Sri Lanka 1st innings 378 (D. Chandimal 80, O. Fernando 50; N. Shah 3-58, Y. Shah 3-83)
Pakistan 1st innings (overnight 191-7, Y. Shah 13)
A. Shafique b A. Fernando 0
Imam-ul-Haq b de Silva 32
B. Azam b Jayasuriya 16
M. Rizwan lbw b R. Mendis 24
F. Alam lbw b R. Mendis 24
A. Salman c de Silva b Jayasuriya 62
M. Nawaz c Dickwella b R. Mendis 12
Y. Shah lbw b Ramesh 26
H. Ali b Jayasuriya 21
N. Ali c Dickwella b Ramesh 1
N. Shah not out 4
Extras (b8, lb1) 9
Total (all out, 88.1 overs) 231
Fall of wickets: 1-0 (Shafique), 2-35 (Azam), 3-65 (Imam-ul-Haq), 4-88 (Rizwan), 5-119 (Fawad), 6-145 (Nawaz), 7-191 (Salman), 8-223 (Hasan), 9-226 (Nauman), 10-231 (Yasir)
Bowling: A. Fernando 20-2-62-1, Jayasuriya 37-10-80-3, R. Mendis 21.1-6-47-5, De Silva 4-0-15-1, Wellalage 6-1-18-0
Sri Lanka 2nd innings
N. Dickwella c Rizwan b Naseem 15
O. Fernando lbw b Yasir 19
K. Mendis lbw b Nawaz 15
A. Mathews c Azam b Salman 35
D. Chandimal c Rizwan b Naseem 21
D. Karunaratne not out 27
D. de Silva not out 30
Extras (b9, lb2, nb2, w1) 14
Total (5 wickets, 50 overs) 176
Yet to bat: R. Mendis, P. Jayasuriya, A. Fernando, D. Wellalage
Fall of wickets: 1-27 (Dickwella), 2-47 (Oshada), 3-59 (K. Mendis), 4-100 (Mathews), 5-117 (Chandimal)
Bowling: Hasan 5-0-24-0 (w1), Naseem 9-1-29-2 (nb1), Yasir 12-2-41-1, Nawaz 11-2-32-1, Nauman 5-0-15-0, Salman 7-1-18-1 (nb1), Azam 1-0-6-0