Sri Lankan opener Dimuth Karunaratne hit a career best 196 which left Pakistan fighting to avoid defeat in the second day-night Test in Dubai on Saturday.
Karunaratne missed a double hundred by four runs but lifted Sri Lanka to an imposing 482 in their first innings before Pakistan finished the second day at 0-51, still trailing by 431.
Openers Sami Aslam (30 not out) and Shan Masood (15 not out) negotiated the 18 overs under light without any major trouble but Pakistan still need 231 to avoid the follow on.
That leaves Pakistan in a spot of bother to square the series after losing the first Test by 21 runs in Abu Dhabi and, more importantly, save their seven-year unbeaten series record in the United Arab Emirates.
It was another brilliant display by the Sri Lankan batsmen, led by left-hander Karunaratne.
Karunaratne deserved a double hundred during a marathon nine-hour stay at the crease but he was unluckily dismissed, playing onto leg-spinner Yasir Shah just before dinner.
The opener hit 19 boundaries and a six, improving on his previous best Test score of 186 made against the West Indies at Galle two years ago.
When on 143 he brought up his 3,000th run in his 44th Test, the 12th Sri Lankan to reach that milestone.
Yasir took 6-184 in a marathon 55.5 overs of hard work and toil on a flat Dubai stadium pitch. His haul makes him the only spinner ever to take five or more wickets in five consecutive Tests.
England's Sydney Barnes holds the record for most consecutive five wicket hauls with seven in as many Tests. Australia's Charlie Turner and Englishman Alec Bedser had six consecutive five-fours -- but all three were fast bowlers.
"It's always my priority to take wickets but the pitch was not assisting on the first day," Yasir said. "We have to fight to our best abilities to win this Test and level the series. Karunaratne played a brilliant knock."
Karunaratne added 146 with skipper Dinesh Chandimal (62) for the fourth wicket before another 88 were put on for the fifth between him and Niroshan Dickwella, who made a rapid 52.
As if that was not enough, Karunaratne put on 59 for the sixth wicket with Dilruwan Perera, who scored a polished 58.
Resuming at 3-254, Sri Lanka lost Chandimal to a lbw decision off Yasir.
Chandimal knocked six boundaries in another enterprising knock which followed his unbeaten 155 in the first Test.
Dickwella's assured knock had five boundaries before he edged pacer Mohammad Abbas to wicketkeeper Sarfraz Ahmed while Perera smashed seven boundaries before becoming Yasir's fifth wicket - his 13th five-wicket haul in 28 Tests.
Abbas then had Suranga Lakmal for eight to finish with 2-100 while Yasir ended the innings by dismissing Nuwan Pradeep for nought.
Pakistan's miseries were compounded in the morning when pace spearhead Mohammad Amir walked off the field after a recurring shin injury sustained late on Friday. He managed to bowl just three overs in the day.