Ireland's historic Test debut ended in a five-wicket defeat, but only after they had given Pakistan a major scare on the final day at Malahide.
The tourists ultimately prevailed with a degree of comfort, reaching a target of 160 thanks largely to Imam-ul-Haq's unbeaten 74 and 59 from Babar Azam.
However, Pakistan had crumbled to 14-3 in Tuesday's morning session, raising the prospect of a stunning Ireland victory after the hosts had been made to follow on.
Mohammad Abbas finished with a five-for and match figures of 9-110 as Ireland were dismissed for 339 having resumed on 319-7, the dangerous Kevin O'Brien failing to add to his overnight score of 118.
Pakistan's subsequent wobble left the match fascinatingly poised, but Imam and Babar restored order and the chase was completed before tea, allowing Pakistan to look ahead to facing England, while Ireland reflect on a promising first venture into the Test arena.
Pakistan have won by 5 wickets. We may not have got the win, but it was a fantastic effort from every one of our team on a historic occasion. They’ve done us proud.— Cricket Ireland (@Irelandcricket) May 15, 2018
Thank you @TheRealPCB for a fantastic Test match.#IREvPAK #BackingGreen pic.twitter.com/9cSBRpOKk7
O'Brien's hundred, which will go down in the history books as his country's first in this format, kept Ireland alive on day four, but he departed to the first ball he faced on Tuesday, edging Abbas to Haris Sohail at slip.
Abbas swiftly removed Boyd Rankin (6) and Tyrone Kane (14) to return second-innings figures of 5-66.
Ireland fought back superbly, though, taking three quick wickets to bring the contest to life.
Tim Murtagh had Azhar Ali (2) caught at first slip and bowled Asad Shafiq (1), either side of Sohail (7) departing to an excellent Ed Joyce catch in the gully off Rankin.
However, debutant Imam and Babar maintained their composure to combine for 38 runs before lunch and their alliance continued well into the afternoon after the latter was dropped by Andrew Balbirnie off Murtagh on nine.
Babar was eventually run out by Balbirnie and Pakistan captain Sarfraz Ahmed (8) fell lbw to Stuart Thompson, but the second Ireland rally came too late and top-scorer Imam fittingly contributed the winning runs.
|BREAKING NEWS: Stricken Salah confident over World Cup hopes|
|Verstappen highlights change in approach amid Rosberg criticism|
|Strinic claims three-year deal at Milan|
|Napoli captain Hamsik considering China offer|
|Chinese outsider Wang shocks Venus Williams in Paris|
|Redemption two years in the making - Ricciardo revels in Monaco glory|
|Flawless Molinari holds off McIlroy at Wentworth|
|Karius ´infinitely sorry´ but thanks Liverpool fans for support|
|Root and Bayliss dismiss ´outrageous´ fixing allegations|
|Giggs: Bale the best Welsh player I´ve seen|
|Ricciardo ends Monaco hoodoo despite mechanical issue|
|Lyon star Fekir denies being close to Liverpool switch|
|Pogba: I learned a lot from Abou Diaby|
|Where next for Real Madrid stars Ronaldo and Bale?|
|Shingler and Hewitt out of Wales tour|
|Kyrgios pulls out of French Open|
|Khan wants to bow out by winning blockbuster Brook fight|
|Is winter coming? Game of Thrones stars descend on Monaco|
|Root urges England´s batsmen to ´find a way´|
|Lovren, Van Dijk absolve Karius of blame|
|We all know where our nipples are - Hansen welcomes tackle trial|
|Rooney would thrive in MLS, says DC United boss|
|Pakistan complete demolition of sorry England|
|Curry, Durant reveal the secret to Thompson´s success|
|Salah will miss World Cup, claims Saudi sports administrator|
|Deschamps marvels at Zidane´s incredible Champions League success|
|FIA satisfied Ferrari ´inside the rules´|
|NSW Origin hopeful Moylan pulls the strings for rampant Sharks|
|Champions League blunders will stay with Karius - Clemence|
|Warriors assuming Iguodala won´t play game seven, Kerr says|
|Lampard confirms Derby talks over vacant managerial position|
|French Open 2018: The science behind Nadal´s clay-court dominance explained|
|Walsh to continue as Bangladesh head coach|
|Bale makes emphatic point after Champions League omission|
|Casemiro: I bet Ronaldo stays at Madrid|
|Brewers pull away for blowout win over Mets|
|Warriors´ outburst sinks Rockets, forces game seven|
|MLS Review: Timbers win sixth straight, Techera scores hat-trick|
|It was like wrestling – Klopp unhappy with Ramos challenge on Salah|
|McKinnon says 49ers aiming to win Super Bowl this season|
|Choo makes history with walk-off home run, Rangers seeking ball|
|Shin-Soo Choo makes history with walk-off home run, Rangers seeking ball|
|Marcelo: I think Cristiano Ronaldo will stay at Real Madrid|
|Miller-Uibo shines as Semenya sets record in Eugene|
|Rose extends lead as Spieth slides|
|Prompt recovery, Salah – Ramos wishes Liverpool star well|
|Indians reliever Miller headed back to disabled list|
|Warriors´ Iguodala to miss game six against Rockets|
|I shouldn´t have done it – Ronaldo accepts future comments mistimed|
|Klopp: Liverpool behind Karius after Champions League horror show|
|Karius´ final blunders could destroy his career – Kahn|
|Zidane understands Bale frustration|
|Bale, Karius send Twitter into overdrive in action-packed Champions League final|
|Ronaldo: It should be called the CR7 Champions League|
|Zidane revels in Madrid´s third successive Champions League title|
|I lost Liverpool the game – Karius apologises for Champions League errors|
|Barcelona congratulate Champions League winners Real Madrid|
|Salah injury update: Egyptian FA calm World Cup fears|
|Ronaldo must stay with Madrid - Zidane|
|Champions League final player ratings: Bale stars as Karius shocker costs Liverpool|
|Cristiano is happy and will continue to be happy – Perez cools Ronaldo future talk|
|Win as a team, lose as a team - Liverpool captain Henderson not blaming Karius|
|Modric: Madrid have built dynasty like Bulls, Celtics and Lakers|
|Where would Cristiano go? - Benzema predicts Ronaldo stays at Madrid|
|We do not think about that - Zidane shrugs off Ronaldo exit talk|
|The divine right of kings: Zidane´s Real Madrid ride luck all the way to greatness|
|Klopp fears Salah will miss World Cup|
|Du Plessis returns, 17 uncapped players selected by South Africa|
|Bale demands playing time after Champions League heroics|
|Ramos: Ronaldo is indispensable to Real Madrid|