Pakistan denied Ireland the dream debut victory by chasing down the 160-run target with the loss of five wickets in their one-off Test against the hosts at Malahide on Tuesday.
A top-notch 74 runs knock of opener Imamul Haq off 121 balls and middle-order batsman Babar Azam's 59 runs innings sealed win for the Sarfaraz-led visiting side.
Ireland, made to follow on, scented a dramatic victory in their debut men's Test as they reduced Pakistan to 14 for three inside five overs.
But Imam-ul-Haq, like the whole Ireland team also making his Test debut, led a Pakistan recovery although the match was still very much in the balance.
At the start of play, Kevin O'Brien's innings came to an end on the first ball of the day. Haris Sohail took the catch at slip after Mohammad Abbas found the edge as O'Brien was dismissed without adding anything to his overnight score of 118.
Abbas in just his sixth Test match took Boyd Rankin and Tyrone Kane's wicket next, completing a five-wicket haul.
Ireland, making their debut in men's Test cricket, were bowled out for 339 in their second innings after being made to follow-on.
Ireland started the day on their highly creditable overnight 64 without loss.
But they lost four wickets in Monday's first session, with left-arm quick Mohammad Amir — who had both openers dropped during a brief spell on Sunday before going off with a knee problem — enjoying a burst of two wickets for no runs in six balls.
It was a heartening sign for Pakistan ahead of their upcoming two-Test series in England that will feature back-to-back fixtures at Lord's (May 24-28) and Headingley (June 1-5).
Amir, however, repeatedly limped around the field on Monday when he was not bowling.
Ireland resumed with veteran opener Ed Joyce, arguably their greatest batsman of all time, 39 not out and captain William Porterfield unbeaten on 23. At that stage they were still 116 runs behind.
The last thing Ireland needed was to gift Pakistan a wicket via a runout and yet that is exactly how an opening stand eventually worth 69 runs ended when Joyce set off for a needlessly tight single before failing to beat Faheem Ashraf's direct hit from midwicket.
The 39-year-old left-hander was out for 43, including six well-struck fours.
Fear that as soon as Ireland lost one wicket, another might follow quickly were proved correct as 69 for one became 69 for two, with Andrew Balbirnie lbw to Mohammad Abbas for nought for the second time in the match as he completed a pair.
Amir struck with his 29th ball Monday when Niall O'Brien, Kevin's brother, had his stumps uprooted for a wicket greeted with the bowler's familiar arms outstretched celebration.
And 94 for three became 95 for four when Amir had Porterfield (32) edging to wicket-keeper Sarfraz Ahmed, the Pakistan captain.
An innings defeat was still a possibility when Amir, given a jail sentence and banned from cricket for five years as a result of his involvement in a spot-fixing scandal during the 2010 Lord´s Test, took his 100th wicket in 31 matches at this level when Gary Wilson was held in the slips by Haris Sohail.
Pakistan´s Shadab Khan celebrates with Mohammad Abbas after claiming the wicket of Ireland´s Stuart Thomson. Photo: Reuters
But Thompson's single off all-rounder Faheem meant Pakistan would have to bat again, while Kevin O'Brien was looking increasingly assured.
Best known for hitting the fastest-ever World Cup hundred, off 50 balls, against England at Bangalore in 2011, Kevin O'Brien made Ireland's maiden Test memorable with his hundred.
Pakistan took the new ball with Ireland 193 for six but Kevin O'Brien´s response was to clip Abbas for a legside boundary.