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.
|Predators sign Ryan Ellis to eight-year, $50M contract|
|Curran, Woakes, Rashid - who makes way for Stokes in England´s Test XI?|
|Griezmann well positioned for Ballon d´Or, says Simeone|
|Criscito: I was on Genoa bridge shortly before collapse|
|Alonso to leave F1: How the Spaniard´s numbers stack up to the greats|
|Rookie LB Roquan Smith finally signs Bears contract|
|De Villiers enjoying relief from ´unbearable´ Proteas pressure|
|Fernando Alonso to leave F1|
|Spalletti extends Inter contract|
|Godin, Koke, Griezmann and Juanfran named Atletico Madrid captains|
|Ronaldo out of hospital after illness|
|Fury: Beating Wilder and Joshua ´very easy´|
|Dickinson retires to take up academy coaching role|
|Cricket the ´sole focus´ for Stokes as he returns to England squad|
|Cheryshev moves to Valencia on loan|
|Mandzukic retires from Croatia duty after World Cup|
|Ben Stokes found not guilty of affray|
|Tottenham issue new stadium update and apology to fans|
|Chelsea flop Bakayoko moves to AC Milan on loan|
|Gabi urges Al Sadd team-mate Xavi to play on|
|Ronaldo leads UEFA Goal of the Season nominees|
|Federer: Djokovic could be caught up in US Open pressure|
|Ronaldo to Juventus a huge boost for Serie A – Matthaus|
|Werner would welcome Ozil Germany return|
|´Perfectionist´ Serena admits to ´unrealistic´ expectations in tennis and motherhood|
|Klopp praises Deschamps and his ´boring´ France|
|LaLiga 2018-19: Bale or Griezmann - Who will step into Ronaldo´s breach as Messi´s main rival?|
|Woods winning 15th major would be greatest comeback in sport – Faldo|
|Retiring Storm great Hoffman not giving up on Finals dream|
|Folau won´t change aerial approach in All Blacks showdown|
|Racism behind Sterling criticism, says ex-Arsenal star Wright|
|Eto´o joins Qatar SC following Ligue 1 links|
|UEFA Super Cup 2018-19: Atletico academy eclipsing Madrid, La Masia|
|UEFA Super Cup 2018-19: Should Real Madrid cash in on Modric?|
|Scintillating Serena sends warning, Azarenka survives opener|
|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|