The 37-year-old right-hander came down the track to off-spinner Saeed Ajmal, trying to loft him over mid-wicket, but only managed to hit it in the air for Ahmed Shehzad to run back and take a good catch.
The former Sri Lanka captain cursed himself and shook his head in disappointment as he walked back but eventually took off his helmet and bandana and acknowledged the cheers from the crowd with a raised bat and a big smile on his face.
Jayawardene had resumed on his overnight score of 49 and reached his 50th test fifty with a sweep off Ajmal for four to fine leg that was greeted with loud applause from the crowd.
On 53, the elegant batsman survived a confident appeal for a caught behind off Wahab Riaz but the third umpire ruled in favour of the batsman as replays failed to confirm the authenticity of the catch taken by wicketkeeper Sarfraz Ahmed.
Jayawardene signed off with the bat with 11,814 runs from 149 tests at an average of 49.84, making him the seventh highest run-getter in the world in test cricket.
Sri Lanka set Pakistan a target of 271 to win. However, Pakistan were 104/5 after 34 overs, with Rangana Herath taking 3 wickets.