Pakistan denied Ireland an unlikely win in their inaugural Test after a nervous start to their run chase at Malahide.
A stunning opening bowling spell raised the tantalising prospect of Ireland becoming the second side to win on Test debut as Pakistan were reeling on 14-3.
But Imam-ul-Haq and Babar Azam shared a 126-run fourth wicket stand as Pakistan battled to their winning target of 160.
The match ended just as rain clouds began to darken over Malahide and the prospect of a draw had surfaced.
Pakistan struggled to complete a relatively modest run-chase against Sri Lanka last year and a furious bowling spell from Ireland’s seamers sent a thrill of expectation around the ground.
Tim Murtagh dismissed Azhar Ali with the fourth ball of the innings, that was nicked to first slip, before extra height from Boyd Rankin accounted for Haris Sohail and Murtagh returned to bowl Asad Shafiq in the next over.
Babar joined Imam in the middle and the pair took the sting out of the Irish attack before both players built half-centuries.
Babar was run out on 59 but Imam, who looked composed throughout his Test debut, struck the winning runs to clinch victory by five wickets. (BBC Sport)