Pakistan survived an almighty scare before condemning Ireland to a five-wicket defeat in the hosts' maiden Test match on day five at Malahide.
Ireland seamers Tim Murtagh (2-55) and Boyd Rankin (1-57) reduced the tourists to 14-3 inside five overs as they began their chase of 160 under overcast skies in Dublin, after the home side had been dismissed for 339 earlier in the day, with Kevin O'Brien unable to add to his overnight 118.
However, debutant Imam-ul-Haq (74no), the nephew of Pakistan great and current chief selector Inzamam, hit his maiden Test fifty and shared a fourth-wicket stand of 126 with Babar Azam (59) to steer the visitors to their target before tea - Andrew Balbirnie left to rue dropping Babar on nine in the slip cordon with the score on 60.
Pakistan subsequently ended Ireland's hopes of becoming just the fourth side to win a Test having followed on, after England in 1894 and 1981 and India in 2001, with each of those victories coming against Australia.
Sarfraz Ahmed's men will now head to England for a two-Test series, with games at Lord's from May 24 and Headingley from June 1, while Ireland can reflect on genuinely threatening to win their inaugural Test, something only Australia, against England in Melbourne in 1877, have achieved.