Their inferior net run rate meant Pakistan had to win big against Sri Lanka in order to pip New Zealand and join group leaders England in the semi-finals.
They racked up 212-8 after Sahibzada Farhan (100) and Fakhar Zaman (84) combined in a T20 World Cup record 176-run opening stand.
They had to restrict their opponents to 147 or less to make the last four but Sri Lanka finished on 207-6 nearly snatching a victory.
Pavan Rathnayake made 58 and Sri Lanka captain Dasun Shanaka smoked an unbeaten 76 off 31 balls.
