|ICC Intercontinental Cup final, day two of five, Dubai:|
|Ireland 187 (61 overs) and 159-2 (46 overs); Afghanistan 182 (77.5 overs)|
Ireland took control of the Intercontinental Cup final against Afghanistan as Ed Joyce's unbeaten 74 helped them move 164 runs ahead with eight second-innings wickets remaining.
The Irish secured an unlikely first-innings lead of five runs as John Mooney's figures of 5-45 helped bowl the Afghans out for 182 in Dubai.
Joyce and Niall O'Brien then produced a third-wicket partnership of 106 to leave the Irish on 159-2 at the close.
O'Brien was unbeaten on 40 at stumps.
The Intercontinental Cup offers ICC associate member countries the chance to play first-class cricket and the Irish have won the competition on three occasions over the past decade.
Having topped the group stage of the competition, Ireland need only a draw in Dubai to clinch the trophy, with holders Afghanistan requiring a victory to hold on to the title.
Afghanistan looked to hold the edge after day one as they finished on 81-3 after bowling Ireland out for 187 on a decent batting track.
Dawlat Zadran had ripped through Ireland's top order to leave them on 67-5 before John Anderson's 55 and Mooney's 33 enabled the Irish to avoid an embarrassing total.
All-rounder Mooney took three wickets early in Afghanistan's innings but the defending champions finished the day on 81-3 and then pushed on to 116-3 in Wednesday's morning session to emphasise their apparent superiority.
However, Mooney then dismissed Rahmat Shah, Kevin O'Brien taking the catch, and the departures of Asghar Stanikzai (41) and Samiullah Shenwari suddenly left the Afghans in some trouble at 133-6.
George Dockrell took the first of his three wickets with the crucial dismissal of Stanikzai while Mooney completed his five-wicket haul by sending Shenwari to the pavilion as Andrew White made the catch.
The Afghans regrouped with captain Mohammad Nabi and Mirwais Ashraf producing a 42-run partnership as the holders moved to within sight of Ireland's first-innings total.
However, Trent Johnston dismissed both of them and Dockrell mopped up the tail with two more wickets, leaving the Irish with their unlikely five-run advantage.
When Ireland batted again, Paul Stirling departed early as he nicked a leg-side delivery from Nabi to keeper Afsar Zazai and William Porterfield's attractive knock of 34 ended in the final ball before tea as he pulled straight to Rahmat Shah.
But that was as good as it got for Afghanistan, Joyce going on to rack up 13 fours in Wednesday's remaining action as he produced some glorious shots in his 132 balls.
O'Brien played an exemplary supporting role as he reached 40 from 105 balls, in a knock which only included two fours.
With plenty of batting to come, Ireland will aim to push their advantage to well in excess of 300 on Thursday before having another bowl at the holders.