Opening batsman Ahmed Shehzad cashed in on a very flat pitch to hit a maiden test century but Sri Lanka hit back through Rangana Herath's triple strike to restrict Pakistan to 291-6 in the decisive third test today.
Shehzad made 147 off 275 balls with 12 fours and a six in just over five-and-a-half hours before he became one of Herath's three victims in the last session on the third day.
Captain Misbah-ul-Haq was unbeaten on 36 as Herath (3-88) also had Sarfraz Ahmed caught behind in the last over of the day.
"It's my debut series and I made century as well, so it's a kind of dream come true for me," Shehzad, who scored 55 in the drawn first test, said.
"My wicket fell at a very wrong time as it's always difficult for a new batsman to come and adjust."
Pakistan remained 137 runs adrift of Sri Lanka, after The Lions declared its first innings at 428-9.
Sri Lanka did well to restrict Pakistan to 169-2 by tea before Shehzad upped the scoring rate soon after. He completed his century off 230 balls with seven fours before smashing another five boundaries and also adding a six to his haul.
Shehzad made an overly ambitious attempt to reverse sweep against Herath, but was unable to avoid dragging the ball back onto his stumps when he looked set to dominate the bowling.
Sri Lanka didn't go for the second new ball and Shaminda Eranga reverse swung the old ball enough to win lbw decision against Asad Shafiq before Herath got a faint edge of Ahmed.
"The captain is there and I think we should play two more sessions and equal their score," Shehzad said. "We will try to make a comeback as we are going after the result in the match."
Herath struck early after tea when Younis Khan (17) was caught behind down the legside as Pakistan had to pay a heavy price of losing four wickets for 122 runs in the last session.
Sri Lanka - leading the series 1-0 and needing just a draw to clinch the series - did well in the first session by conceding just 66 runs after Pakistan resumed at the overnight 19-0.
Shehzad and Khurram Manzoor (52) labored for only 23 runs in the first hour with Shehzad hitting two legside boundaries off fast bowler Suranga Lakmal.
Manzoor was very cautious, hitting only one boundary in the session, when he cut Eranga to point in the 17th over of the day.
The openers put on Pakistan's best first wicket stand of the series - 114 runs - but were too defensive against both seamers and the left-arm spin of Herath, who constantly bowled outside leg stump and tested the patience of batsmen.
But the Sri Lanka tactic annoyed Shehzad.
"They can't bowl us out with negative bowling in a proper test match," Shehzad said. "It's a do or die match for us and they were afraid that we were going after runs."
But Sri Lanka's premier batsman Kumar Sangakkara was quick to defend Herath.
"A lot of batsmen do not have the patience anyways when you bowl those kind of lines," Sangakkara said. "The plan was quite positive to try and get them to hit against the line."
Sri Lanka captain Angelo Mathews also frustrated the openers with some intelligent field placings and didn't allow them to rotate strike too often with five fielders inside the 15 meters on the legside.
Pakistan needed a significant increase in the run rate to take the win that would square the series, but Manzoor and Shehzad were tied down after the break as they took almost three hours to reach their fifties, with 84 further runs gained in the second session.
Shehzad reached his half century off 150 balls with five fours and Manzoor soon followed him to complete his seventh test fifty off 120 balls with four boundaries.
Eranga finally got the breakthrough when Manzoor, who faced 125 balls with four boundaries, tried to flick him down the legside and Ali perished soon afterwards as Perera lured him to drive off a well flighted delivery and found the outside edge to Mathews.
Who's your favourite New Zealand medium pace bowler?