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.
|Serena coasts, difficulties for Halep and Muguruza´s marathon|
|Lowry retains Abu Dhabi lead|
|Djokovic battles past Tsonga, young guns flourish|
|Louisville airport to be renamed in Muhammad Ali´s honour|
|Emery not thinking about Ozil speculation|
|Sri Lanka hopeful over Kusal Mendis finger injury|
|Oman 3 Turkmenistan 1: Last-gasp Al-Musallami guarantees progression|
|Emery wants Cech to end career ´in a good moment´|
|Japan 2 Uzbekistan 1: Shiotani stunner seals comeback and top spot|
|Calhanoglu deal ´financially impossible´ for Leipzig|
|Not seen at Aus Open since Nadal, Djokovic and Murray in 2009 – ´Next Gen´ make move|
|Martial: Solskjaer lets me express myself|
|Djokovic sees off Tsonga to reach third round|
|Returning Cousins calls Warriors ´the most hated team in sports´|
|Halep injury ´nothing dangerous´|
|Warner picks up elbow injury in Bangladesh|
|Mkhitaryan returning to Arsenal training next week|
|Leeds United pounce for Real Madrid goalkeeper Casilla|
|Watson lights up Gabba before power cut forces abandonment|
|Superb Serena blows Bouchard away|
|Tevez, Hulk, Oscar, Lavezzi - how the CSL stars Dembele is following to China fared|
|Thiem retires from Australian Open|
|Osaka ´not telling´ when it comes to injury niggle|
|Fabinho enjoying Klopp´s management style|
|Halep battles past Kenin in Melbourne|
|Hartley to miss England´s Six Nations opener|
|Dembele departs Spurs for Guangzhou R&F|
|Nacho convinced Isco remains important to Real Madrid|
|Warriors star Curry sets NBA record|
|Raonic survives four-hour marathon against Wawrinka|
|Osaka powers through to Aus Open third round|
|Irving dominates in Celtics´ win over Raptors|
|Irving called LeBron this week to apologise|
|Ajax star De Jong wants to resolve future ´quickly´|
|Payton on Rams CB Peters: I have great respect for him|
|Rockets star Harden matches Chamberlain with historic performances|
|Nishikori survives Karlovic test in Melbourne|
|Vieira reunion felt really weird - Henry|
|´#BetAgainstUs´ - Edelman and Pats embracing underdog status|
|Van der Vaart: Isco the best player in the world|
|I haven´t seen Guardiola or Klopp do that – Lampard unhappy with Bielsa|
|Real Madrid always play to win, insists Casemiro|
|Royals pitcher Skoglund suspended for 80 games after testing positive for PEDs|
|Ronaldo and Juve celebrate Supercoppa Italiana title with Mayweather|
|We are not going to talk about Morata - Simeone reluctant to discuss striker|
|Madrid weak in Leganes loss, says Solari|
|Bologna and Banvit seal Champions League play-off spots|
|LeBron James to miss Thunder & Rockets games but nearing practice return|
|Leganes 1 Real Madrid 0 (1-3 agg): Isco starts as Solari´s side go through despite defeat|
|NFL playoffs 2019: X-factor for each NFC team|
|Mahomes: Chiefs must not repeat mistakes against Patriots|
|Higuain´s Supercoppa benching due to virus, says Milan boss Gattuso|
|Brown fires back at Arians over ´diva´ comments|
|Stone heading home from West Indies tour with back injury|
|Shazier will continue rehab with intention of playing again|
|That´s why we signed him! Allegri hails Supercoppa match-winner Ronaldo|
|Monaco on worst home run in club´s history after Nice draw|
|Atletico Madrid 3 Girona 3 (4-4 agg): Simeone´s side out on away goals|
|Gregg Williams is Jets´ new defensive coordinator|
|Ronaldo: Supercoppa triumph just the start for Juve|
|Monaco confirm Batshuayi talks|
|You know more than me! Bielsa´s Barcelona research surprised Guardiola|
|Juventus 1 AC Milan 0: Ronaldo heads Bianconeri to Supercoppa glory|
|Kane injury cannot be excuse for Tottenham – Pochettino|
|Woods to open 2019 schedule at Torrey Pines|
|Reported Liverpool target Dabbur to undergo Sevilla medical|
|Lebanon v North Korea: Radulovic calls on players to make history|
|MLS MVP Martinez signs five-year contract with Atlanta|
|WBC set deadline for Wilder-Fury rematch|
|Iran 0 Iraq 0: Team Melli top Group D after dull draw|