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.
|DeGrom strikes out 12, Mets hit 5 homers in win over Yankees|
|Djokovic needs nine MPs as Murray crashes out|
|Murray unsure of US Open readiness after Cincinnati exit|
|Van Dijk: Alisson making difference at Liverpool|
|Johnson saves eight MPs but Djokovic prevails|
|Federer anxious ahead of Cincinnati comeback|
|Tevez relishing Messi reunion|
|Ronaldo arrival has taken Juve forward in Europe – Nedved|
|Serena steamrolls Gavrilova in Cincinnati return|
|Packers QB Rodgers doesn´t regret criticising team-mates|
|Indians OF Martin recovering from life-threatening bacterial infection|
|Shoulder injury sends Royals starter Duffy to DL|
|Yankees place Sabathia on DL with right knee inflammation|
|Aubameyang urges Emery to capitalise on his ´spark´ with Lacazette|
|Anderson can play until he´s 40, says Bayliss|
|Keita living childhood dream after securing Inter switch|
|49ers to sign veteran RB Alfred Morris, Kyle Shanahan says|
|Arnaiz leaves Barcelona for Leganes in €5m deal|
|Tottenham´s move to new stadium delayed|
|Roosters-bound Hall suffers ACL injury|
|Murray suffers Cincinnati defeat to Pouille|
|No Cech mate - Arsenal goalkeeper hits back at Bayer Leverkusen|
|Halep first to seal WTA Finals spot|
|Veteran Carmelo Anthony pens one-year Rockets deal|
|Runners and Ryders: Poulter closes in on Team Europe spot|
|Gameiro presented by Valencia after departing Atletico Madrid|
|World Cup winner Kimpembe extends PSG contract to 2023|
|AC Milan send Locatelli on loan to Sassuolo|
|South Africa´s Etzebeth set for return from injury|
|Rafinha ´very likely´ to stay at Barcelona|
|No dual Ryder Cup role should Woods make USA team, says Furyk|
|Inter complete Keita deal|
|David Silva announces retirement from international football|
|Modric in Real Madrid´s UEFA Super Cup squad amid Inter links|
|Neville hopes Shaw is on to something special after first United goal|
|Unchanged England waiting on Stokes verdict|
|Yates brothers to race Vuelta together|
|Kalinic explains why he rejected World Cup medal|
|Furyk excited to see Woods´ return to form|
|Liverpool ignoring media´s champions chat, says Van Dijk|
|Suspended Smith replaces Kohli as top-ranked Test batsman|
|Tiger fanfare inevitable but it´s time to recognise Koepka as the star he is|
|Dier: Tottenham will shut up transfer critics|
|Fernandes leaves West Ham for Fiorentina on loan|
|´No chance´ Willian would have stayed at Chelsea under Conte|
|Vettel confident he can catch Hamilton|
|Cane dismisses talk of All Blacks limiting haka|
|Zaha promises Palace commitment as contract talks continue|
|Real Madrid defender Odriozola to miss UEFA Super Cup|
|All Blacks wary of Pocock threat|
|Bayern Munich confirm no ligament damage for Alaba|
|Nicklaus hails Koepka´s great year after US PGA triumph|
|Keita ready to ´explode´ at Inter|
|Halep: Stephens makes me a better player|
|Manchester United loan Wilson to Aberdeen|
|Beale backs Hodge to start in Rugby Championship opener|
|Bakayoko arrives for AC Milan medical|
|Australia favourites for Rugby Championship opener, says Hansen|
|Muller hails Lewandowski: That´s why Bayern won´t let him go|
|Allegri eyes Champions League after watching Ronaldo score first Juventus goal|
|LaLiga 2018-19: Barcelona or Real Madrid - whose close-season transfers have been better?|
|Fekir almost certain to stay at Lyon, says Aulas|
|Tuchel unaware of PSG deal for Kehrer|
|MLS Review: Rooney´s heroics lift DC, Villa inspires NYC|
|Sale strikes out 12 in Red Sox´s win over Orioles|
|Scott buoyed by Bellerive display|
|Edmund, Mannarino win Cincinnati openers|
|WATCH: Rooney saves open goal before setting up last-gasp winner|
|Kovac praises three-goal Lewandowski but thanks Heynckes|
|Nadal withdraws from Cincinnati Masters|