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.
|MLS Review: Red Bulls upstage Atlanta thanks to Wright-Phillips brace|
|Warriors breeze past Rockets in game three|
|We have a quality squad – Man City chairman hints at caution in transfer market|
|Wise cruises to maiden PGA Tour victory at Byron Nelson|
|Matic: United can fight for Premier League and Champions League with experience|
|Golden Knights GM on Stanley Cup Finals berth: I don´t know how we did it|
|I did a ´s*** job´ defending LeBron James – Morris|
|Dembele suffers sprained right ankle|
|We know Fellaini´s not going to renew with United – Mirabelli suggests Milan move|
|Cavs´ Lue not satisfied with just one win|
|They even whistled at Torres – Simeone backs Griezmann|
|I arrived as a boy, I leave as a man – Iniesta in emotional Barcelona farewell|
|Lingard: Wembley loss my worst feeling in football|
|Cahill: Conte uncertainty affecting Chelsea|
|Sarri has run out of time – Napoli chief De Laurentiis|
|Barca boss Valverde salutes departing Iniesta|
|I feel like I´ve been run over by a truck or had 15 pints - Crutchlow|
|Four sent off as Ajaccio win chaotic Le Havre play-off on penalties|
|Sweden win shoot-out to retain world title|
|De Vrij penalty was destiny for Inter - Icardi|
|PSG? Maybe one day - Pogba coy over long-term future at Manchester United|
|Messi wins fifth European Golden Shoe|
|Gattuso calls for more malice at Milan|
|Barcelona 1 Real Sociedad 0: Coutinho stunner lights up Iniesta´s farewell|
|Lazio 2 Inter 3: Spalletti´s men seal Champions League qualification with stunning comeback|
|Royals reach play-offs as Kings XI come up short|
|Nadal sees clearly after Rome rain is gone|
|Double whammy for Zverevs as Mischa bows out in Geneva|
|Atletico Madrid pay fitting tribute to tearful Torres|
|Hull FC claim derby spoils, Dragons off the bottom|
|Buzarnescu battles through as McHale impresses in Nuremberg|
|Neymar an artist who will not need special treatment - new PSG coach Tuchel|
|Atletico Madrid 2 Eibar 2: Torres bows out with a double|
|Napoli 2 Crotone 1: Milik and Callejon condemn visitors to the drop|
|Iniesta starts on Barcelona goodbye but Messi rested|
|Nadal rallies after rain break to dethrone Zverev in Rome|
|AC Milan 5 Fiorentina 1: Cutrone brace secures Europa League group stage spot|
|I think I made a fantastic decision - Garoppolo key to Sherman joining 49ers|
|FIFPro appeals to FIFA over Guerrero World Cup ban|
|Neymar made mistake joining PSG - Rivaldo|
|Simple for Simon as outstanding Yates extends Giro advantage|
|Ulster qualify for Champions Cup as Biggar makes history|
|Neymar tired of rumours and staying at PSG, president Al-Khelaifi claims|
|Beaten Halep calms injury concerns ahead of French Open|
|Van der Vaart´s Midtjylland nightmare set to end|
|It has been a crazy ride - Klopp proud of Liverpool ahead of Champions League showdown|
|Raonic pulls out of French Open|
|Liverpool youngster Alexander-Arnold not overwhelmed by England call-up|
|Torres captains Atletico Madrid on farewell|
|Otaegui claims second European Tour win at Belgian Knockout|
|Green: Warriors play best when we feel threatened|
|Daredevils dump out defending IPL champions Mumbai|
|Fan shows off Monk face tattoo on bottom|
|Bayern Munich chief Hoeness rules out spending spree|
|Fury to take on Albanian Seferi in Manchester next month|
|Mourinho mind games won´t distract from Manchester United´s paused progress|
|My motivation is intact - Ranieri open to offers following Nantes exit|
|Shields would probably have made All Blacks squad - Hansen|
|Willian fuels rift talk by hiding Conte with emojis in cup photo|
|Marquez extends lead at Le Mans as Dovizioso crashes again|
|Top-six mentality a boost to England´s World Cup hopes – Southgate|
|Dominant Svitolina retains in Rome as Halep sustains injury scare|
|I´d play for free! - Fifita desperate for State of Origin call-up|
|Plea satisfied with Nice exit as big changes beckon|
|Boateng open to leaving Bayern for move abroad|
|Napoli slam ´shameful and offensive´ Juventus celebrations|
|Red Star´s open-top bus goes up in flames|
|Klopp rejects Liverpool´s Champions League final underdogs tag|
|Root trusts batting form to ´click´ for England|
|Matic wants Man Utd to back Mourinho in transfer market|