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.
|Storm and Raiders snatch dramatic wins|
|Boateng desperate for ´best in the world´ Neuer to play|
|Great players have to play here - Real Madrid´s Marcelo continues Neymar courtship|
|Salah can win Ballon d´Or with Champions League triumph, says Luiz|
|Roland Garros wins ´exactly the same´ for Nadal regardless of Federer involvement|
|Rebels romp past Sunwolves, Crusaders retain top spot|
|Halep ´stronger mentally´ as she seeks first grand slam title|
|Cipriani on bench for Baa Baas clash|
|Ronaldo´s rival Salah shifts focus back to Liverpool versus Real Madrid|
|Two arrested in Kiev after clashes before Champions League final|
|Johnny Nelson leads tributes after death of Brendan Ingle|
|Batshuayi puts off Chelsea plans until after World Cup|
|Devon Smith back in Windies squad, Hamilton earns maiden call-up|
|Thiago hints at uncertain Bayern Munich future|
|Dhananjaya pulls out of Windies tour following death of father|
|I feel great - Kerr keeps faith with Warriors on the brink|
|Ronaldo: I can´t be compared with Salah|
|Buffon agent backs Paris Saint-Germain move|
|ICC confirms smart watches prohibited|
|Real Madrid v Liverpool: Champions League final in Opta numbers|
|Mane sends 300 Liverpool shirts to Senegal village for Champions League final|
|Arthur will not join Barcelona before December, Gremio insist|
|Real Madrid v Liverpool: Key battles in the Champions League final|
|Trout hits 15th HR, Bundy strikes out 14|
|Rockets star Paul dealing with hamstring injury|
|Does he only care about his hair? - Denmark coach Hareide slams Pogba, France|
|Rockets push Warriors to brink of elimination|
|World number 84 Kicker suspended for match-fixing|
|WATCH: Paul shimmies in Curry´s face|
|Copa Libertadores Review: Estudiantes into last 16 after thrilling win over Nacional|
|Ronaldo: Cristiano and Neymar would be good together at Madrid|
|Rockets honour Santa Fe victims, first responders at game five|
|Real Madrid rejected €150m offers for Asensio – agent|
|Marshall, Baldwin react strongly to Trump´s comments on NFL anthem stance|
|Nabura handed six-week ban for wild kick|
|Pedroia to return for Red Sox on Friday|
|Warriors´ Iguodala ruled out for game five against Rockets|
|Na leads as Spieth makes solid start at Colonial|
|James Harden, LeBron James headline 2017-18 All-NBA first team|
|Manchester United target Fred to decide future after World Cup|
|´Incredible´ Salah is like Messi, says Ronaldo|
|Salah a big candidate for Ballon d´Or - Muller|
|Message from coach keeping Masters champion Reed grounded|
|Anybody can really win it - Seles feels French Open is wide open this year|
|Mambo number 5! - Non-league star channels Lou Bega hit|
|Pakistan to stop wearing smart watches after ICC intervention - Hasan|
|Saha hails ´great man´ Ferguson as legendary Man Utd boss continues recovery|
|Emery´s depth of knowledge impressed Arsenal´s Gazidis|
|Conceicao extends Porto contract|
|Lomax impresses as Saints overrun Tigers|
|McIlroy in contention at Wentworth as Bjerregaard sets the early pace|
|Bad light calls time on Thiem, Wawrinka out in Geneva|
|Garitano in, Canales out at Real Sociedad|
|Caparros accepts new role at Sevilla|
|Pliskova downed by Larsson after drawing Serena in Paris|
|They´re using the anthem as fake patriotism - Warriors coach Kerr critical of NFL|
|Lyon win record fifth Women´s Champions League title|
|French Open 2018: Doing the unthinkable - the men most likely to topple Nadal|
|French Open 2018: How can Rafael Nadal be stopped?|
|Steve Smith named as marquee player for Global T20 Canada|
|Can Emre play? Yes he Can... and so can Milner|
|Liverpool working to help fans after flight cancellations|
|Abbas and Hasan torment sorry England|
|Xavi ´thrilled´ to sign two-year Al Sadd extension|
|Holtby extends Hamburg contract despite relegation|
|Nadal begins French Open defence against Dolgopolov|
|Serena drawn to play Pliskova in French Open first round|
|FA condemns assault of match official|
|Bologna confirm Donadoni departure|
|Yates lead halved in Giro d´Italia|