Herath spun one across Misbah's bat to hit the off stump to leave Pakistan at 265-6 at tea on the fourth day, leading by just 42 runs in the second innings with one full session and a day to play.
Misbah's valiant effort of 97 helped Pakistan avoid their first-ever innings defeat against Sri Lanka before his 412-minutes resistance ended just 20 minutes before tea. At the break, Sarfraz Ahmed (39) and Bilawal Bhatti (seven) were at the crease.
Misbah, who took 38 balls to add to his overnight score of 53, hit eight boundaries and a six under difficult circumstances with Dubai stadium lights on due to cloudy weather most of the fourth day.
He added an invaluable 129 for the fourth wicket with Younis Khan (77), 52 for Asad Shafiq (23) for the fifth and 45 for the sixth with Sarfarz to help Pakistan avoid innings defeat but finally succumbed to some persistent effort from Herath who has figures of 2-105.
The first Test in the three-match series ended in a draw in Abu Dhabi last week.
Pakistan resumed on 132-3 and needed Younis and Misbah to dig deep but Younis tried to drive a slightly wide delivery from Suranga Lakmal, managing only to edge it to wicketkeeper Prasanna Jayawardene, who held his eighth catch of the match.
Younis batted for 235 minutes and hit five boundaries, adding 129 runs for the third wicket with his skipper.
Sri Lanka took the second new ball with the score at 198-4 and were rewarded in the second over when paceman Shaminda Eranga had Shafiq caught in the slip.
Sarfraz has batted aggressively, hitting six boundaries and staying a step ahead of the crease to blunt the seam and spin.
Paceman Nuwan Pradeep has figures of 2-50 while Laklam and Eranga had a wicket each.
Source: AFP