But left-hander Shakib (114) and Mahmudullah (102) turned the tide with a stand of 224 - Bangladesh's highest one-day global partnership for any wicket - thus ending New Zealand's bid to reach the last four.
Bangladesh will be praying that England beat Australia at Edgbaston tomorrow (or indeed for Australia to be part of a third consecutive rained-out affair) and then they will play the victor of Sunday's South Africa vs India game, in a knockout match for a spot in the final.
Shakib scored 114 runs from 115 deliveries, hitting 11 boundaries and a six during his stay in the middle.
Shakib completed his fifth and one of his most iconic ODI hundred in 111 balls with help of nine fours and a six. After that, Mahmudullah 102* off 107 balls ensured the applause would continue by also bringing up his century with a heave to the square-leg fence. Taskin bagged two wickets to play his part. New Zealand have the pedigree, but it would be foolish to rule out Bangladesh, given their improved showing in this format in recent years.
When Trent Boult bowled Shakib, the match had already been all but won. When they began, Bangladesh was under the pump and not even its most ardent fan was thinking of victory. Before that, they had lost all 15 away ODIs against New Zealand.
New Zealand were 201 for four in the 39th over. He weathered that phase, and when Mahmudullah joined him, the two seamlessly shifted gears in a stunning counter-attack. "He took the pressure off me".
Generally during partnerships it is seen that the two batsmen in the middle communicate with each other but the Bangladesh innings saw nothing of that sort.
Bangladesh produced another Cardiff victory every inch as remarkable as the 2005 triumph over Australia to keep their Champions Trophy hopes alive and eliminate New Zealand. Both men found the boundary at will as the stand progressed, always keeping the required run-rate within lassoing distance.More news: Sixers take guard Fultz with top pick of NBA Draft
With the ball, Bangladesh had once again proven miserly in the slog overs, conceding just 62 runs in the last 10 overs and picking up four wickets.
The Bangladesh bowlers were absolutely spot on, partiularly Mosaddek Hossain Saikat who clinched three wickets for 13, bowling just three overs. The call was answered by the skipper Kane Williamson and Ross Taylor. The much expected batsman Corey Anderson, got out for a duck.
Black Caps captain Kane Williamson said it was a "very dry" pitch.
As far as Playing XI is concerned, New Zealand is interestingly going with the same squad that suffered an 87-run defeat against England in the second group clash.
Choosing to bat first, New Zealand made a brisk start to their innings before opener Luke Ronchi was dismissed by Taskin Ahmed for 16.
The competition rules state if teams are equal on points, the team with the most wins in group matches will be placed in the higher position.
"They have serious quality players". Mossadek ended the innings with 3/14 off 3 overs.
Bangladeshi spinner might have bowled only 3 overs, but it was enough for him to do job done for his team. It was to be the introduction of third bowler Taskin Ahmed that turned the tide as his consistent line and length caused problems for the New Zealand batsmen as they failed to get bat to ball on numerous occasions.