Ireland lost their maiden Test match to Pakistan by five wickets on Tuesday, but went down fighting at Malahide in Dublin.
Starting the day on 319 for seven with Kevin O'Brien resuming on 118, Ireland were only able to add 20 runs to their overnight total to set Pakistan a target of 160.
O'Brien, who became Ireland's first-ever Test centurion on Monday, was out to the first ball he faced, but Tim Murtagh and Boyd Rankin ploughed into Pakistan's batting lineup early on to add a touch of drama to the proceedings.
Opener Azhar Ali was the first to depart for two, caught by Paul Stirling at first slip after a good length delivery by Murtagh, before Haris Sohail and Asad Shafiq were swiftly sent packing to leave the visitors reeling on 14 runs for three wickets.
That was as good as it got for Ireland.
Opener Imam-ul-Haq, nephew of former captain and current chief selector Inzamam-ul-Haq, steadied the ship with a fine Test debut, stroking an unbeaten 74 that provided the platform for victory.
Imam's 126-run fourth-wicket stand with Babar Azam was enough to break the Irish resistance, but only after Andy Balbirnie let an opportunity to send Babar back to the dressing room early slip through his fingers at third slip.
That miss proved costly, with Pakistan piling on 50 runs in the next 10 overs before Balbirnie made amends, helping to run out Babar on 59.
Though Pakistan were 20 runs from victory at that stage Ireland refused to lie down, with Stuart Thompson getting skipper Sarfraz Ahmed out lbw on eight runs, but Imam kept his head amid all the chaos, and struck the winning runs.
Decide plea against Sreesanth's discharge in IPL spot-fixing: SC to Delhi HC
Manohar elected unopposed, to serve 2nd term as ICC chairman
IPL Preview: With play-off hopes hanging by a thread, Mumbai take on KXIP
Will Afghanistan spinners challenge Indian batsmen?
PIX: Virat Kohli finds his cheerleader in wife Anushka