The 22-year-old right-hander made 147 in only his second Test as Pakistan scored 291-6 at close on the third day, still trailing by 137 runs over Sri Lanka's first innings total of 428-9 declared.
Pakistan lost Sarfraz Ahmed for five, caught behind off spinner Rangana Herath in the last over of the day. Misbah-ul Haq was unbeaten on 36.
With two days remaining and Pakistan lagging well behind they will be hard pressed to enforce a result, with Sri Lanka happy for a no-result affair.
While Pakistan struggled for runs, it was a memorable day for young Shehzad.
Shehzad added a quick 56 for the fourth wicket with Misbah but Pakistan's slow and cautious batting amidst some tight bowling blunted their efforts to get closer to Sri Lanka's total.
Pakistan, trailing 1-0 in the three-match series after losing the second Test in Dubai by nine wickets, managed 150 runs in the first two sessions after resuming at 19-0, losing opener Khurram Manzoor (52) and Azhar Ali (eight).
Sri Lanka mostly employed a six-man leg-side field as their bowlers made runs hard to come by, with Pakistan adding only 23 in the first hour's play.
But Shehzad, who made 55 in the drawn first Test in Abu Dhabi, paced up the innings in the last session, helping Pakistan to 122 runs in the two hours but Pakistan lost four wickets.
Shehzad reached his hundred with a couple towards cover off spinner Dilruwan Perera, taking 230 balls to reach the three-figure mark studded with seven fours. His second fifty came off 80 balls.
He was finally bowled off a reverse sweep against Herath. Shehzad batted for 339 minutes, hit 12 fours and a six.
Shehzad said he was happy to score a hundred.
"It's my debut series and I made a century, so it's a kind of dream come true for me," said Shehzad. "I was surprised with their negative approach although they had 400 runs on board, they had packed the leg side and it made runs hard to come by."
Shehzad hoped Pakistan enforce a result in the match.
"I think we should play two more sessions and equal their score and we will try to come back into the match, we are going for the result in the match, it's a do-or-die for us."
Sri Lankan batsman Kumar Sangakkara said Sunday's first hour will be crucial.
"I think we played well, if we get a couple of wickets in the morning tomorrow, especially Misbah, then we would be able to do quite well in the Tests," said Sangakkara.
In a slow but steady start Shehzad put on 114 for the opening wicket with Manzoor.
Manzoor fell soon after lunch as he tried to glance a leg-side delivery from paceman Shaminda Eranga but only managed to snick it to wicketkeeper Prasanna Jayawardene.
He hit four boundaries during his 125-ball innings.
(AFP)
Ali, dropped for the first two Tests, battled for 27 deliveries and departed after edging off-spinner Dilruwan Perera to slip for his first Test wicket.
Both Manzoor and Ali challenged the umpire's decisions but ended up wasting both Pakistan's referrals.
Experienced batsman Younis Khan didn't last long either as he fell caught behind off Herath for 17. Herath had the best figures amongst Sri Lankan bowlers with 3-88.