Pakistan 310 for 9 dec (Ashraf 83, Shafiq 62, Shadab 54, Murtagh 4-45) and 160 for 5 (Imam 74*, Babar 59) beat Ireland 130 (K O'Brien 40, Abbas 4-44, Shadab 3-31) and 339 (K O'Brien 118, Thompson 55, Abbas 5-66) by five wickets
Scorecard and ball-by-ball details

In the end, Ireland were beaten in their maiden Test, suffering the same fate as eight of the other ten members of cricket's most exclusive club. Imam-ul-Haq, the debutant opener, and Babar Azam fashioned the significant partnership Pakistan needed to avert disaster after they had slipped to 14 for 3 chasing 160. But that hardly begins to tell the story of Malahide.

Although Ireland only managed to added 20 runs to their overnight 319 for 7, century-maker Kevin O'Brien falling to his first ball on the fifth morning, they had everyone in the ground - and many far beyond - dreaming of a victory worthy of folklore when Tim Murtagh and Boyd Rankin plucked out three wickets in the first five overs of Pakistan's chase. Not only could Ireland envisage becoming the second team after Australia to win their first Test, they would have done so after following on - a feat achieved three times in the history of the game.

Pakistan, haunted by recent failures when set a small-but-testing target, knew they were being set up as the falls guys. Having dismissed Ireland for 130 first time around, it was galling enough that they had managed to pass 300, led by O'Brien's historic innings. Now Pakistan were in trouble on a green seamer against green opponents (in Test terms), with their two most-experienced batsmen back in the dressing room.

Instead, the youngsters stood up. Imam has already dealt with the pressure of expectation - his uncle, Inzamam-ul-Haq, is one of Pakistan's greatest batsmen, as well as the chief selector - and he played an innings of calm authority to record his maiden half-century, characterised by composure and sound shot selection. He has a tale to tell of Malahide, too, having seemingly been knocked unconscious going for a single from the first ball of the match.

The fourth-wicket stand between Imam and Babar, eventually worth 126, steered Pakistan away from calamity, but it was one that Ireland should have broken when the game was still very much alive. In the second over after lunch, Murtagh located his groove once again - and located Babar's outside edge, only for Andy Balbirnie to drop a straightforward catch diving to his left at third slip. Pakistan could have been 60 for 4, but instead they added 50 runs in the next ten overs. Ireland's chance was gone.

Babar is also a batsman under great scrutiny, as Pakistan adapt to life after the retirements of Misbah-ul-Haq and Younis Khan. His ODI batting average is 51.11; going into this match, he averaged less than half of that from 11 Tests. This was his fifth half-century, but he was run out with Pakistan still 20 from victory - Balbirnie half-atoning for his drop with a good bit of fielding.

Still Ireland would not lie down, Stuart Thompson claiming the wicket of Sarfraz Ahmed lbw to narrow the margin further. Until the final ball was bowled, and the winning runs struck by Imam, the first Irish men's Test XI in history did their ICC Full Member status proud.

Ireland arrived at the ground in the morning knowing that plenty needed to go their way if the "Miracle of Malahide" was to be fully realised. O'Brien going on to a big hundred would have been the first target, but he could only lean on his bat handle and curse himself after driving hard at Mohammad Abbas in the second over of the day and sending a simple catch to slip. Abbas pocketed the last two wickets, as well, to finish with his second five-for in six Tests.

Instinct said that Pakistan might contrive to make life difficult for themselves yet. Murtagh set nerves jangling in his opening over, as Azhar Ali edged a curving delivery to first slip, his attempts to walk down the pitch and combat the swing in vain. Haris Sohail struck one boundary before fencing a rising Rankin delivery to gully and when Asad Shafiq lost his off stump prodding forward at Murtagh, the roars around the ground fuelled Irish belief.

Ireland fought to become a Test nation, and believed that they were good enough. Now the rest of the world, surely, believes them too.

Alan Gardner is an associate editor at ESPNcricinfo. @alanroderick