Mohammed Amir shrugged off a nagging knee problem to be the pick of the bowlers, finishing the day with figures of 3-57 as he reached 100 Test wickets.
Ireland's debut in Test cricket ended in a five-wicket defeat as Pakistan debutant Imam-ul-Haq hit an unbeaten 74 at Malahide on Tuesday.
And when Pakistan lost three wickets - two to paceman Tim Murtagh - in the opening 27 balls of the reply, Ireland had a strong chance of becoming the first team to win its maiden test - after Australia against England in 1877 in cricket's first test.
Ireland's players react as Pakistan's Asda Shafiq loses his wicket.
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. Ireland are back in action on Sky Sports on June 27 and June 29 when they play India in Twenty20 internationals at Malahide.
Both batsmen added 126 for the fourth wicket and brought Pakistan near the finish line.
Trivia Tuesday: NBA Lottery picks from non-power schools
The team will have an 8.4 percent chance of receiving the seventh pick and a 0.4 percent chance of receiving the eighth pick. Crazier stuff has happened, though, and adding another blue-chip prospect to either one of these teams seems nearly unfair.
Nisar lashes out at Nawaz Sharif over Mumbai attack remarks
A spokesman for Sharif said: "At the outset, statement of Nawaz Sharif has been grossly misinterpreted by the Indian media". The Mumbai attacks-related trials are stalled in a Rawalpindi anti-terrorism court.
Pakistani terrorists behind 26/11 Mumbai attacks, admits Nawaz Sharif
Union Minority Affairs Minister Mukhtar Abbas Naqvi told ANI, "Pakistan is exclusively responsible for 26/11 terrorist attack". Six heavily armed terrorists from Pakistan attacked the Pathankot Air Force station in the early hours of January 2, 2016.
'We were definitely anxious at 14 for three, but we were confident we had a good batting side, ' said Pakistan captain Sarfraz Ahmed. 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.
Although it was nearly inevitable that the upset was too far gone, Ireland further added to a respectable scoreline and outstanding match in general producing a further outing through Stuart Thompson's dismissal of Safraz Ahmed for 8, Pakistan now at 152-5.
What were your highlights from Ireland's first ever Test match? But after this wonderful four days of all that is good in the longest form of the game, they might like to revisit that number upwards. Too late, we were already back in Kansas.
O'Brien became the first Ireland player to score a Test century on day four to lift his side to 319-7 by stumps and a lead of 139, but perished to the first ball he faced on day five, snicking an out-swinger from Mohammad Abbas (5-66) behind to Haris Sohail at slip while on the drive.
Pakistan declared their first innings on 310-9 early on day three.
Ireland's first Test match in global cricket took a lengthy little spell of 144 years to take place but it started with a bang as, in the opening ball of the match, two Irish players collided firmly with Pakistan batsman Imam-ul-Haq, leaving him sprawled on the deck. (Faheem Ashraf 83, Asad Shafiq 62, Shadab Khan 55; T Murtagh 4-45, S Thompson 3-62).