Having won the toss and elected to bat, Afghanistan stumbled early on as they lost captain Gulbadin Naib and Hashmatullah Shahidi in back-to-back deliveries to Afridi, who produced a blistering opening spell with the new ball.
Former skipper Asghar Afghan and Ikram Alikhil built a 64-run stand before Afghan was cleaned up by leg-spinner Shadab Khan for 42.
Wicketkeeper-batsman Alikhil (24) holed out to left-arm spinner Imad Wasim but Najibullah Zadran's scored a patient 54-ball 42 to take the Afghans past the 200-mark.
Afridi, playing only his 18th ODI at the age of 19, returned to remove Zadran and Rashid Khan to finish as pick of the Pakistan bowlers with 4-47.
The game was marred by a clash between the supporters of both teams in the stands at Headingley, with ESPNcricinfo reporting at least two fans have been evicted from the match.
Back-to-back wins against South Africa and New Zealand have handed 1992 champions Pakistan a chance of making the semi-finals but they must beat Afghanistan to keep their qualification hopes alive.