Rahat's hostile bowling left Sri Lanka tottering at 35-3 in their second innings during a rain-interrupted morning session before they reached lunch on the third day at 55-3.
Upul Tharanga was unbeaten on 29 and skipper Angelo Mathews was on 11, with the hosts 118 runs ahead with seven wickets in hand.
Rahat bowled first innings century-maker Dimuth Karunaratne for 10 and yorked Lahiru Thirimanne for no score in an inspired eight-over opening spell.
Play was held up twice by passing showers, keeping the hard-working ground staff on their toes as they rushed in the covers to guard both the wicket and the outfield.
Also Read
The tourists, added six runs to their overnight score of 209-9 before they were all out for 215 in the day's second over in reply to Sri Lanka's 278.
All six of the runs came off the bat of Sarfraz Ahmed, who remained unbeaten on 78.
Last man Imran Khan was bowled by off-spinner Tharindu Kaushal for zero as Sri Lanka gained a lead of 63 runs.
The series is tied at 1-1 after Pakistan won the first Test in Galle by 10 wickets and Sri Lanka took the second in Colombo by seven wickets.