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.
|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|
|Pogba and Mourinho disagreement over Instagram video, confirms Pereira|
|Nuggets coach Malone signs contract extension|
|Mayweather accepts Khabib´s challenge: ´We´re fighting´|
|Slovenia sack Kavcic as head coach|
|Morgan and Rashid star as England win rain-reduced ODI in Sri Lanka|
|Romagnoli aims to make Gattuso proud in Milan derby|
|Naldo signs Schalke extension|
|Bills to start quarterback Anderson against Colts with Allen out|
|O´Sullivan makes 147 at ´hellhole´|
|Barcelona know when captain Messi is angry – Abidal|
|Bertens loss hands Pliskova last WTA Finals berth|
|Liverpool star Mane undergoes hand surgery|
|F1 Raceweek: Happy hunting ground for title-chasing Hamilton - US GP in numbers|
|Canelo signs record-breaking DAZN deal|
|England hit by another Vunipola injury absence|
|Gruden: Oakland Raiders ´aren´t tanking´|
|Chiesa focused and happy at Fiorentina|
|We´ll see what´s possible - Henry not limiting Monaco´s ambitions|
|Wembley sale off after Khan offer withdrawn|
|Football needs people like Arsene - Pires keen for Wenger return|
|Abbas five-for torments woeful Australia as Pakistan take control|
|Henry: Wenger and Guardiola inspirations for my coaching career|
|Pires backs Henry and Vieira for Ligue 1 success|
|Bolt rejects Valletta offer|
|Wenger ready for January return to management – but where?|
|NBA 2018-19: The LeBron James effect on teams he has joined|
|Svitolina qualifies for WTA Finals after Pliskova loses|
|Genoa will sell ´superstar´ Piatek, admits president|
|Moutinho targets European qualification with Wolves|
|Embiid: 76ers-Celtics isn´t a rivalry, they always kick our a**|
|Vinicius ´calm´ as he waits for Real Madrid chance|
|Nothing else to say - Ramos posts clip of supposed Sterling stamp|
|Chiellini joins Mind the Gap campaign to help players prepare for retirement|
|Injured Kusal Perera replaced by Kusal Mendis in Sri Lanka squad|
|Big names return for Scotland´s November Tests|
|Essien tells Loftus-Cheek to stay and fight for Chelsea chance|
|Nainggolan relishing challenge of first Milan derby|
|Curry: Slap me if I tire of championship celebrations|
|Sevilla don´t fear Messi or Barca – Kjaer|
|Low: Dropped Muller is still very important for Germany|
|Hayward put ´dark memories´ behind him with Celtics return|
|I hope I´m in Klopp´s good books! - Koeman jokes after resting Wijnaldum|
|Rested Fellaini should be fit for Manchester United, says Martinez|
|France´s mentality must be right - Lloris|
|Bellinger seals dramatic win as Dodgers level up NLCS|
|Curry, Durant lead Warriors past Thunder|
|Kjaer surprised by LaLiga-leading Sevilla as Machin´s men remain grounded|