Imran Khan took five wickets to bowl Sri Lanka all out for 313 runs at lunch on day four, but Pakistan have been handed a mammoth target of 377 to win the third and final Test in Pallekele.
Sri Lanka began the day on 228-5 largely thanks to an impressive partnership between Angelo Mathews and Dinesh Chandimal.
The pair continued their dominance in the morning session, but Khan claimed two wickets in two balls to swing some momentum in Pakistan's direction.
Khan picked off Chandimal lbw for 67 and he followed that up by dismissing Dhammika Prasad, who went for a duck first ball.
Despite Khan's impressive display, Mathews continued to dominate with the bat and he pulled up his fifth Test hundred before being taken out for 122 runs off 252 balls.
On the stroke of lunch, Khan ended Sri Lanka's second innings with a further two wickets, but Pakistan have a mountain to climb to win the series, which currently sits at 1-1.