Pakistan debutant Imam-ul-Haq saw his side to victory as Ireland's first match in men's Test cricket ended in a gallant last-day defeat by five wickets at Malahide on Tuesday. Pakistan, set a seemingly modest 160 to win, after earlier making Ireland follow-on, collapsed to 14 for three before lunch on the fifth day. But 22-year-old left-handed opener Imam, the nephew of Pakistan selection chief and former Test batsman Inzamam-ul-Haq, responded to the pressure with 74 not out - his maiden fifty at this level.
Together with Babar Azam, who made 59 after being dropped on nine, he kept Ireland at bay during a fourth-wicket stand of 126. Imam hit the winning runs as grey clouds threatening rain hung over Malahide. Victory was a good way for Pakistan to prepare for the first of a two-Test series against England at Lord's starting on May 24.
Just four balls into their chase, Pakistan saw Azhar Ali edge Tim Murtagh to Paul Stirling at first slip. Haris Sohail (seven) fell next, well taken in the gully by Ed Joyce off towering fast bowler Boyd Rankin as Ireland's two former England internationals combined.
And 13 for two became 14 for three in 4.3 overs when Middlesex paceman Murtagh produced a superb delivery to bowl Asad Shafiq between bat and pad for one.
Imam, who bats in spectacles, showed a maturity beyond many of his more experienced top-order colleagues.
He struck two fine fours off Stuart Thompson, a square cut followed by a square drive. Ireland needed to take every chance that came their way but, with Babar yet to add to his interval score, he was dropped in the slips by Andrew Balbirnie.
Imam, having cover driven a four off Rankin, completed a 61-ball fifty with seven boundaries - the third time he had reached the landmark this tour after half-centuries in warm-up matches against Kent and Northamptonshire. Babar, cashed in to make a 61-ball fifty.
But with Pakistan 20 runs shy of victory, a mix-up saw Babar run out. There was still time for Ireland to take a couple more wickets but by then the match had escaped their grasp. Earlier, Ireland were dismissed for 339 in their second innings.
Kevin O'Brien, who on Monday became the first Ireland batsman to score a Test hundred, fell to his first ball Tuesday as Mohammad Abbas had him caught by Haris at slip for 118.
The Irish, resuming on 319 for seven, saw Abbas then take three wickets for 12 runs in 22 balls, the paceman finishing with an innings haul of five for 66 in 28.3 overs.
Only three sides in the 141-year history of Test cricket had won after being made to follow on and only one men's team - Australia in the inaugural Test against England at Melbourne in 1877 - had enjoyed a victory in their debut match at this level.
Ireland were facing an innings defeat when man-of-the-match O'Brien came in at 95 for four but, ably assisted by Stuart Thompson, who made 53, he turned the tide during a seventh-wicket partnership of 114.
But after Tyrone Kane had seen out Tuesday's opening over from Mohammad Amir, who took his 100th Test wicket on Monday, Abbas struck.
O'Brien going down on one knee to attempt a slashing drive off a wide half-volley from Abbas, nicked to Haris.
A crestfallen O'Brien bowed his head in frustration and dropped his bat as he trudged off the field.
But the 34-year-old had every reason to be proud of an innings that spanned five hours, 44 minutes and saw him face 217 balls with 12 fours.
Scoreboard
Pakistan 1st Innings 310-9 dec (Faheem Ashraf 83, Asad Shafiq 62, Shadab Khan 55; T Murtagh 4-45, S Thompson 3-62)
Ireland 1st Innings 130 (Mohammad Abbas 4-44, Shadab Khan 3-31)
Ireland 2nd Innings (following-on, overnight: 319-7)
=============================================
E. Joyce run out (F. Ashraf) 43
W. Porterfield c S. Ahmed b M. Amir 32
A. Balbirnie lbw b M. Abbas 0
N. O'Brien b M. Amir 18
P. Stirling lbw b M. Abbas 11
K. O'Brien c H. Sohail b M. Abbas 118
G. Wilson c H. Sohail b M. Amir 12
S. Thompson b S. Khan 53
T. Kane b M. Abbas 14
B. Rankin b M. Abbas 6
T. Murtagh not out 5
=============================================
Extras: (b1, lb20, nb2, w4) 27
=============================================
Total: (all out, 129.3 overs, 579 mins) 339
=============================================
Fall of wickets: 1-69 (Joyce), 2-69 (Balbirnie), 3-94 (N O'Brien), 4-95 (Porterfield), 5-127 (Stirling), 6-157 (Wilson), 7-271 (Thompson), 8-321 (K O'Brien), 9-332 (Rankin), 10-339 (Kane)
Bowling: Amir 29.2-9-63-3; Abbas 28.3-10-66-5 (1nb); Rahat 23-3-75-0 (2w); Faheem 18-3-51-0 (1nb, 1w); Shadab 30.4-7-63-1
=============================================
Pakistan 2nd Innings (target: 160)
=============================================
A. Ali c Stirling b Murtagh 2
Imam-ul-Haq not out 74
H. Sohail c Joyce b Rankin 7
A. Shafiq b Murtagh 1
B. Azam run out (Balbirnie/Thompson) 59
S. Ahmed lbw b Thompson 8
Shadab Khan not out 4
=============================================
Extras: (nb5) 5
=============================================
Total: (5 wkts, 45 overs, 199 mins) 160
=============================================