Pakistan hammered Bangladesh by 94 runs at Lord’s but failed in their highly unlikely task of edging out New Zealand of the last World Cup semi-final place.
The 1992 winners needed victory by a record margin of at least 308 runs to finish fourth on a better net run-rate.
An Imam ul-Haq century and 96 from Babar Azam saw them post 315-9 before they dismissed Bangladesh for 221.
Shakib Al Hasan shined with 64 for the Tigers but seamer Shaheen Afridi (6-35) produced a match-winning spell.
Pakistan could not reach the semi-finals once Bangladesh reached 8-0 in the second over of their chase, confirming New Zealand in the last four with Australia, India and England.
England will finish third and New Zealand fourth, with the group winners to be decided on Saturday.
Leaders Australia will top the group if they beat South Africa at Old Trafford but if the defending champions lose, India can overtake them by defeating Sri Lanka at Headingley.