Afghanistan’s cricket team claimed a historic first Test win on Monday as they beat Ireland by seven wickets.

Rahmat Shah and Ihsanullah Janat scored fifties for the war-torn country as they chased down 147 for victory on day four in Dehradun, India.

Afghanistan were steered to their target by a 139-run partnership between Shah, who made 76, and debutant Janat, who hit an unbeaten 65.

Shah, a top-order batsman, registered his second fifty of the match after making 98 in Afghanistan’s first innings score of 314.

With three needed to win, Afghanistan lost Shah and then Mohammad Nabi in successive deliveries before Hashmatullah Shahidi came to the crease and hit the winning boundary to trigger celebrations in the Afghanistan camp.

Ace spinner Rashid Khan, who is second in the ICC one-day international rankings, had played a key role in the historic win by taking five wickets on Sunday’s day three to help dismiss Ireland for 288 in their second innings.

Khan returned career-best figures of five for 82 to stall Ireland’s resurgence after Andy Balbirnie and Kevin O’Brien had hit gritty half-centuries.

Balbirnie made 82 and O’Brien 56 before a 10th-wicket 58-run partnership between James Cameron-Dow and Tim Murtagh set up the potentially tricky chase for the Afghans.

Spinner Andy McBrine had opener Mohammad Shahzad caught behind for two in the final session on day three before Janat and Shah played out the last few overs.

The overnight batsmen were tested by the Ireland bowlers early in Monday’s morning session with Janat surviving a reprieve on 18.

Stuart Thompson spilled an easy catch at extra cover off George Dockrell and Janat cashed in alongside the in-form Shah.

Paceman Yamin Ahmadzai and spinner Mohammad Nabi took three wickets each on the opening day to bowl out Ireland for 172.

Shah and skipper Asghar Afghan, who made 67 to steer their team to a crucial first-innings lead of 142.

For Ireland Tim Murtagh stood out with scores of 54 not out and 27 batting at number 11.

It was Afghanistan’s second Test outing after making their debut last year when they lost to India inside two days in Bangalore. Ireland have also played two five-day games.