The result is one of the biggest upsets in the history of the World Cup which was first played in 1975.
Ireland, requiring a revised target of 128 to win in 47 overs, won with a six over mid-wicket by captain Trent Johnston off Azhar Mahmood. There were 8.2 overs still remaining
The result means Pakistan, who also lost their opener against West Indies on Tuesday, are out and Ireland are in pole position to progress to the Super Eights, probably with the hosts.
Kevin O'Brien was 16 not out after his brother Niall had earlier scored a crucial 72 on St Patrick's Day, the Irish patron saint.
Ireland were coasting to victory at 113-5 but the 35th over of the innings bowled by Rao Iftikhar included two wickets and that created a tense finale
Pakistan were earlier dismissed for just 132 in 45.4 overs as seamer Boyd Rankin claimed 3-32, including 13 wides. Pakistan's top scorer was extras with 29.
Ireland tied their first match with Zimbabwe on Thursday.