Resolute half-centuries by Ben Stokes and Jonny Bairstow led England to a four-wicket victory against Pakistan and a 4-0 lead in the five-match one-day international series on Thursday. Stokes stroked a nearly run-a-ball 69 and Bairstow, included at the last minute in place of the injured Jos Buttler, made 61 as England chased down Pakistan's 247-8 with two overs to spare. Moeen Ali, 45 not out, hit a winning six off Pakistan captain Azhar Ali as England posted 252-6 at Headingley. Pakistan's top order struggled against spinners Adil Rashid, who took 3-47, and Moeen, 2-39, before captain Azhar Ali's 80 and Imad Wasim's quickfire late unbeaten 57 off 41 balls gave the visitors a competitive total. "We did a fantastic job with the ball, a special mention for the spinners and the guys who came in, David Willey and Chris Jordan," England captain Eoin Morgan said. "Pakistan made early inroads but Stokes, Moeen, and Jonny made match-winning contributions. Jonny was outstanding but he's finding it hard to get into a winning side, which is a good problem for us." Bairstow and Stokes combined in a 103-run stand for the fifth wicket after Mohammad Irfan snared both openers and the dismissals of Joe Root (30) and Morgan (11) left their team struggling at 72-4 in the 15th over. Earlier, after winning the toss and opting to bat, Pakistan struggled to pace its innings around captain Azhar's half-century against some disciplined England bowling. "It was a bit more of a competitive game but again we were a few runs short," Azhar said. "Irfan bowled well on his comeback but unfortunately his calf was cramping up ... and we couldn't break partnerships in that middle period." Stokes took two well-judged catches to send both opening batsmen Sami Aslam (24) and Sharjeel Khan (16) packing before spinners Moeen, who didn't concede a boundary off his 10 overs, and Rashid struck at regular intervals. Azhar tried to accelerate but holed out to mid off while attempting to clear Rashid over his head, and Moeen had Mohammad Nawaz (13) stumped in his last over to make Pakistan struggle at 180-7. However, Wasim took charge and hit seven fours and a six in his unbeaten half-century and lifted the total by contributing 56 runs off 48 balls for the eighth wicket with Hasan Ali. The inclusion of Irfan, who flew to England last week in place of the injured Mohammad Hafeez, made an early impact on England's top order, which achieved a world-record 444-3 in the third ODI at Trent Bridge on Tuesday. Alex Hales, who made England's highest individual ODI score of 171 on Tuesday, got a thick edge off Irfan and was out for 8. Root, who scored five successive ODI half-centuries, looked good until he top-edged Hasan to Irfan at fine leg. Pakistan missed a good but hard chance when Stokes was dropped on 34. The last match of the series will be at Cardiff on Sunday.