Ireland have reduced Afghanistan to 136-5 as they pursue a challenging 347 for victory at the end of Day 3 of the InterContinental Cup final in Dubai.
Niall O'Brien's 87 and three wickets from George Dockrell proved pivotal.
Trent Johnston gave Ireland the perfect start as they looked to win the trophy for the fourth time, trapping Shabir Noori (8) in the first over of the Afghanistan reply.
However, the retiring former skipper left the field for the last time just one additional over before tea.
First-innings hero John Mooney dismissed Nowroz Mangal (23), brilliantly caught off the inside edge by Niall O'Brien, clearly relishing his return behind the stumps.
George Dockrell then took centre stage, claiming three wickets in quick succession, including that of the dangerous Mohammad Shahzad (39).
The Somerset left-armer swooped brilliantly to take a sharp return low down to his right.
He then bowled Ashgar Stanikzai (2) and trapped Afsar Zazai (0) to leave Afghanistan reeling on 85-5.
Ireland at that juncture were dreaming of a win inside three days, but resolute defence from Rehmat Shah (33*) and Mohammed Nabi (25*) ensured Afghanistan got through to the close without further damage - their sixth wicket stand currently worth 51.
Earlier in the day Ireland had lost Ed Joyce (78) in the first over but a fourth wicket stand of 81 between Niall O'Brien (87) and Andrew White (39) saw Ireland remain very much in the ascendancy.
White, John Anderson and John Mooney all fell cheaply as Mohammed Nabi (4-38) bowled superbly, but a breezy 47 in 43 balls from Kevin O'Brien (9 fours) and a pugnacious 31 from Trent Johnston in his final innings for Ireland ensured the lead went beyond the psychologically important 300 mark for a final total being 341.
Ireland will start day four as the strongest of favourites to complete a historic treble, however they will be keen to remove the ever dangerous Mohammed Nabi, who has proved such a ferocious competitor in the past.
Scores in brief:
Ireland: 187 all out and 341 all out (95.1 overs, Niall O'Brien 87, Ed Joyce 78, Kevin O'Brien 47, Andrew White 39, William Porterfield 34, Trent Johnston 31, Mohammed Nabi 4-38, Rehmat Shah 2-58, Mirwais Ashraf 2-63, Dawlat Zadran 2-110).
Afghanistan: 182 all out and 136/5 (43 overs, Mohammad Shahzad 39, Rehmat Shah 33*, Mohammed Nabi 25*, Nowroz Mangal 23, George Dockrell 3-26).