Kevin O'Brien scored Ireland's first Test century to bolster hopes of at least avoiding defeat in their debut in the five-day game against Pakistan.
Ireland resumed day four on 64-0 in their second innings having been forced to follow-on by the visitors, who reduced the hosts to 157-6 to seemingly put them in position for an emphatic victory.
Mohammad Amir, having been troubled by a knee injury on day three, looked back to fitness and form on Monday and did much of the damage with figures of 3-57.
But Amir and the rest of the Pakistan attack were frustrated by the brilliance of O'Brien, who forged a pivotal partnership of 114 with Stuart Thompson (53) and an unbroken one of 48 with Tyrone Kane (8), staying unbeaten on 118 to guide Ireland to 319-7 at the close on an historic day at Malahide.
Ireland therefore lead by 139 going into the final day, with a draw and even a victory still within their grasp after being applauded off the field by Pakistan at stumps following O'Brien's magnificent effort.
Opener Ed Joyce (43) was run out by Faheem Ashraf before Andy Balbirnie went for a duck five balls later as Ireland made a dreadful start to the day.
The prospect of defeat loomed ever larger after Amir dismissed any doubts over his ability to produce pace by sending Niall O'Brien's (18) off and middle stumps careering out of the ground, before then claiming the scalp of captain William Porterfield (32).
O'Brien's arrival at the crease prompted the first signs of Ireland resistance but wickets continued to tumble around him until Thompson joined him in the middle.
Their defiance ensured Ireland would not only avoid an innings defeat but also give their own attack something to bowl at in Pakistan's second innings.
And, though a ripper from Shadab Khan removed Thompson, O'Brien proved immovable, his belligerent strokes keeping the scoreboard ticking before he wrote his name in the history books by sneaking two through point to bring up his hundred.
O'Brien and Kane withstood pressure from Amir, Rahat Ali and Mohammad Abbas late in the day, and Ireland go into the last three sessions with the unexpected dilemma of deciding how long to bat before attempting to bowl Pakistan out to seal a seismic shock win.
|LeBron tells Lakers coach Walton: I´m always fresh!|
|Mayweather should come back to fight me - Alvarez|
|Goerges battles past Vekic, Kasatkina wins all-Russian tie|
|Ask 32,000 Gibraltarians if the Nations League is meaningless - Styche|
|They´re going to speak about it for years - Azhar reflects on comical run-out|
|Garcia in the mix as weather hits Andalucia Valderrama Masters|
|From lacking a ´football brain´ to signing a new contract – the Mourinho-Shaw saga|
|Alonso teases Indy 500 return as Hamilton reveals NASCAR temptation|
|Guptill ruled out of Black Caps´ UAE tour|
|UEFA investigating PSG-Red Star fan clashes|
|Just ´another weekend´ for champion-elect Hamilton|
|G League will offer $125K to top prospects in lieu of NCAA one-and-done route|
|Chargers defensive end Bosa ´a few weeks´ away from return, says father|
|Bale back in full Real Madrid training|
|Roma supporter found not guilty of inflicting GBH on Liverpool fan Sean Cox|
|´Fantastic´ Neuer will prove he´s still the best, says Lloris|
|Perez secures Force India stay|
|Australia wait on Khawaja scan|
|Shaw signs Manchester United extension|
|Jones lays down challenge to snubbed England star Cipriani|
|West Ham´s Pellegrini rejects Dzeko speculation|
|Emery fails to assure Ramsey of Arsenal future|
|Pakistan on course for victory after Babar 99 and farcical run out|
|Canelo ready to leave comfort zone to face Fielding|
|Eriksen ready for Tottenham return, Pochettino confirms|
|Titans coach rocked by Hurrell´s Rhinos switch|
|Rubin Kazan suspended from UEFA competition for FFP breach|
|Real Madrid could sack Lopetegui if results don´t improve, says Essien|
|On-court coaching would add to drama - Mouratoglou|
|Babbel lauds ´top class´ Ronaldo after Juventus switch|
|Carmelo Anthony: Rockets bench role challenging mentally|
|Maqsood preferred to Amir in Pakistan T20 squad|
|Make Ramsey Arsenal captain, don´t let him leave – Wilshere|
|Kaneria admits guilt in spot-fixing case|
|No coach can work miracles – Ibrahimovic defends under-fire Mourinho|
|Morgan earns England recall, Cipriani overlooked|
|Reavie leads CJ Cup, solid start from Koepka|
|Juventus kicked me out to sign Ronaldo – Higuain|
|England forward Hughes given six-week ban|
|Injured Halep withdraws from WTA Finals|
|Ronaldo exit makes all the difference for Real Madrid – Luxemburgo|
|Manchester United´s Chelsea Blues and other one-sided rivalries|
|Babbel fears for Kovac´s Bayern future|
|Bradley homers again, Red Sox take 3-1 lead over Astros|
|Ayton, Doncic shine on NBA debuts|
|Leonard focusing on future after Raptors debut|
|MLS Review: Rooney stunner seals DC win, Sounders clinch play-off spot|
|Pochettino ´proud´ of Dier for Ramos tackle|
|Wallabies name three uncapped players for All Blacks clash|
|Lakers coach Walton will monitor LeBron´s minutes, plans to use deep rotation|
|Lloris: United´s Pogba unfairly judged because of transfer fee|
|´Phenomenon´ Mbappe deserves Ballon d´Or, says Buffon|
|Dodgers on cusp of World Series after beating Brewers|
|Mata braced for ´difficult month´ at Man United|
|WATCH: Rooney scores wonderful free-kick for DC United|
|Kaino handed five-week ban for striking Roberts|
|Bears star Khalil Mack ´day-to-day´ with ankle injury|
|Anthony has ´a clearer understanding´ of his role with Rockets|
|Brewers remove Miley after one batter against Dodgers|
|Rams rule out Kupp for 49ers game|
|Giants owner Mara to talk with Beckham Jr|
|Bamberg battle back to claim Champions League win|
|MLB investigated alleged Astros sign stealing, found no wrongdoing|
|Timberwolves star Wiggins to donate $22 for every point this NBA season|
|Red Sox´s Sale won´t start game five of ALCS|
|Tsitsipas and Shapovalov advance at Stockholm Open|
|Witsel to Dortmund is signing of the season - Martinez|
|Pique confident Nadal will play in 2019 Davis Cup|
|Seeds suffer in Moscow and Luxembourg|
|Johnstone grabs hat-trick as England ease past France|