Ed Joyce scored an unbeaten half-century as Ireland staged a determined comeback on the second day of their Intercontinental Cup Final against Afghanistan in Dubai.
Phil Simmons' side will resume proceedings on Thursday morning in a commanding position after reaching stumps on 159-2, a lead of 164.
Joyce ensured the batting failures of day one were not replicated as he and Niall O'Brien (40) put on an unbeaten third-wicket stand of 106, after Ireland's bowlers had earlier dragged their side back into the match.
John Mooney picked up where he left off on Tuesday by completing his first international five-wicket haul with two wickets either side of George Dockrell's dismissal of Asghar Stanikzai, who had added 42.
The defending champions threatened to surpass Ireland's first innings total of 187 with a patient 42-run stand between captain Mohammad Nabi and Mirwais Ashraf.
However, Trent Johnston - who is playing in his final game before retiring - struck twice in quick succession to expose the lower-order as Afghanistan crumbled to 182 all out.
Left-arm spinner Dockrell took advantage of some reckless shots to finish with figures of 3-52 as the final four wickets fell for just seven runs.
Joyce and O'Brien then went about adding to the slender lead with an energetic partnership as they negotiated the final session relatively untroubled, after openers William Porterfield and Paul Stirling had fallen in the first 10 overs.
Porterfield scored a quickfire 34 but was dismissed the delivery before tea as he swept Nabi straight to fine-leg after Stirling had become Dawlat Zadran's fifth wicket of the match.