“The last two years were tough for me as there was a lot of talk on my injury,” he said. “But thankfully I am here and played a responsible knock. I was under pressure because we needed to take the lead, so I had to play a responsible knock which I did.”

Earlier in the day, Pakistan too were struggling at 316-6 and were in danger of conceding a healthy lead with Herath using all his experience and guile.

The 39-year-old left-arm spinner, who now has 394 wickets in 84 Tests, gave his team the much-needed wicket of a resolute Azhar Ali, luring him into an uppish drive which was brilliantly caught at short mid-wicket by a diving Mendis.

Azhar’s defiant knock of 85 lasted more than five hours and included four boundaries, but with his dismissal Pakistan’s hopes of building a lead looked slim.

But Sohail had other ideas as he added an invaluable 50 for the ninth wicket with tail-ender Hasan Ali to lift Pakistan from 340-8.

Sohail hit seven fours and two sixes before holing out to paceman Nuwan Pradeep, who finished with 2-77.

Hasan’s whirlwind 25-ball 29 featured three sixes and two fours.

The second and final Test — a day-night affair — will be played in Dubai from October 6.