Barry McCarthy took his first five-wicket haul for Ireland as they beat Afghanistan by 51 runs in the second one-day international to set up a series decider.

The seamer sat out Ireland's heavy defeat in Tuesday's opener but he stated his claim for a regular spot by taking five for 46 to help ensure Afghanistan fell well short of their target of 272.

McCarthy removed both openers and then returned at the death to end Afghanistan's hopes of wrapping up victory in the series ahead of Sunday's final match.

After winning the toss and batting first in Sharjah, Ireland made a strong start with Will Porterfield (47) and Paul Sterling (82) putting on 115 for the first wicket.

George Dockrell hit an unbeaten 62 off 48 balls to push Ireland up to 271 for nine and then took the crucial wicket of Rahmat Shah as Afghanistan stumbled to 220 all out.