Afghanistan batsman Rahmat Shah fell two runs short of a maiden Test century as Ireland fought back in their Test match in Dehradun, ending day two 22-1 trailing by 120 runs.
Resuming on 90-2, having bowled Ireland out for 172 of the first day, Rahmat and Hashmatullah Shahidi shared a 130-run third-wicket partnership as Afghanistan moved in to the lead.
However, with Ireland toiling Andy McBrine made a vital breakthrough, trapping Shahidi lbw for 61 before Tim Murtagh claimed the vital wicket of Rahmat, who agonisingly chopped on a length ball on 98.
Captain Asghar Afghan played an important hand, striking six fours and four sixes during his 67 off 92 balls, to help build his side's lead but Ireland's bowlers fought back to limit their first-innings deficit.
Stuart Thompson was the pick of the pack, finishing with 3-28 as he saw the dangerous Mohammad Nabi caught at midwicket for a three-ball duck, had Afghan caught behind and wrapped up the innings when Wafadar Momand was caught at slip as Afghanistan were bowled out for 314, a lead of 142.
But, Ireland's second innings got off to a disastrous start as opener William Porterfield was caught behind off Yamin Ahmadzai for a two-ball duck leaving Andy Balbirnie (14 not out) and Paul Stirling (eight not out) to battle it out for the remainder of the day.