Teenage seamer Shaheen Afridi claimed Pakistan's best World Cup figures to secure a 94-run win over Bangladesh at Lord's.
The 19-year-old bagged a career-best 6-35, taking his tournament haul to 16 in five matches, as Bangladesh faltered to 221 all out in reply to Pakistan's 315-9.
Afridi's return was not the only star turn of the day after team-mate Imam-ul-Haq (100) became the youngest Pakistan player to score a World Cup hundred, laying the foundations for his team's fourth win in a row.
Bangladesh seamer Mustafizur Rahman also made the honours board as he followed up his 5-59 against India with figures of 5-75, while Shakib Al Hasan (64) the first batsman to pass 600 runs in the tournament.
The all-rounder contributed his seventh score of 50 or more in the tournament - a haul that matches Sachin Tendulkar's 2003 record and includes two hundreds - and finished the tournament with total of 606 runs at an average of 86.57.
Pakistan arrived at Lord's knowing they had to win by at least 316 runs to overtake New Zealand in the race for the last place in the semi-finals, and although they won the toss, their mission improbable quickly looked impossible.
Opener Fakhar Zaman (13) failed to fire and although Babar Azam (96) and Imam (100) shared a stand of 157, Pakistan's best of the tournament, the run-rate rarely threatened six-an-over.
Babar progressed serenely towards three figures after being badly dropped by Mosaddek Hossain at backward point on 57 - passing Javed Miandad's mark for the most runs scored in a World Cup by a Pakistani batsman - only to fall lbw to Mohammad Saifuddin's inswinging yorker with four runs still needed.
Imam would not be denied, though, reaching his seventh ODI hundred off 99 balls before treading on his stumps as he attempted to work Mustafizur to leg.
Spinner Mehidy Hasan Miraz deserved a wicket for a controlled display of bowling and it came when Mohammad Hafeez (27) picked out Shakib at deep square to leave Pakistan 248-4 off 43 overs.
Their hopes of reaching 300 seemed to reduce when Haris Sohail became Mustafizur's 100th ODI wicket - the seamer the joint-fourth fastest to the mark alongside Shane Bond and behind Rashid Khan (44 games), Mitchell Starc (52) and Saqlain Mushtaq (53).
Any thoughts Sarfaraz Ahmed had of injecting some pace into the innings were quickly put on hold as he was hit on the elbow by a fierce straight drive off Imad Wasim's bat - the skipper unable to get out of the way at the non-striker's end - and after a lengthy spell of treatment he was forced to retire hurt.
Saifuddin wasted little time in bowling Wahab Riaz for two with a clinical yorker and Mustafizur produced an athletic caught and bowled, catching Shadab Khan one-handed, leaving Imad to provide the cameo required to hoist Pakistan past 300.
The left-hander played the slower ball particularly well, striking the ball cleanly on his way to 43 from 26 balls but missing out on a fifty when he uppercutted a Mustafizur off-cutter to third man.
Mustafizur grabbed his five-for with the very next ball as Mohammad Amir top-edged an attempted cut but there was to be no hat-trick as captain Sarfaraz returned to the crease to ensure Pakistan saw out their overs.
Their total of 315-9 meant Pakistan had to bowl Bangladesh out for seven runs or less to progress to the semi-finals, a score quickly achieved but only after Haris had dropped Soumya Sarkar (22) at slip.
Soumyar failed to cash in when Fakhar took a sharp, low catch off Amir at point before Shaheen Afridi castled Tamim Iqbal (eight) with a slower ball that brushed the inside edge.
Bangladesh slipped to 78-3 when Mushfiqur chopped Wahab on but Shakib's form remained supreme - the all-rounder posting his seventh score of fifty or over in the tournament.
Liton Das (32) could not stay with him - Afridi inducing a false drive to cover - and Shakib's outstanding tournament came to an end when he snicked the seamer behind.
Mossadek's departure for 16 was swiftly followed by a double strike for Shaheen as Bangladesh wilted and fittingly the seamer wrapped up matters by cleaning out Mustafizur.
Watch every match at the Cricket World Cup live on Sky Sports, continuing with Sri Lanka vs India from 10am on Sky Sports Cricket World Cup and Australia vs South Africa from 1pm on Sky Sports Mix.
Sky customer? With Sky VIP - your free loyalty programme - you could be right at the heart of the Ashes action with a once-in-a-lifetime opportunity to join the captains on the pitch for the coin toss at Edgbaston. Enter now on the My Sky app.