New Zealand 289 for 7 (Guptill 105, Shakib 4-55) beat Bangladesh 288 for 7 (Mahmudullah 128*, Soumya 51) by three wickets
Scorecard and ball-by-ball details

New Zealand ended the group stage with a perfect six-out-of-six record, but their bowlers were fully challenged for the first time in this World Cup as they sneaked a three-wicket win over Bangladesh. The win ended a five-year losing streak against Bangladesh, and it was was hard work all the way for the tournament favourites.

Mahmudullah, Soumya Sarkar and Sabbir Rahman made New Zealand count to 288, the biggest total they have conceded in this tournament so far, before Shakib Al Hasan's four-wicket haul nearly derailed their chase. But Martin Guptill's sixth ODI hundred set an excellent platform, before Grant Elliott and Corey Anderson kept them going in the final ten overs. Tim Southee struck a six and a four in the penultimate over to complete the win.

Guptill struck 11 fours and two sixes in his 100-ball 105, and added 131 for the third wicket with the struggling Ross Taylor, who made 56 off 97 balls. Elliott and Anderson made 39 each on the back of each other, the latter's contribution more immediate to the final equation, hitting three sixes and three fours in his 26-ball blitz.

Shakib, the stand-in captain, bowled himself and Taijul Islam at the start of New Zealand's chase. It was the first time two left-arm spinners had opened the bowling in an ODI. It worked almost immediately, with Shakib picking up McCullum and Williamson in the fifth over, but Guptill, who survived a close leg-before shout on 19, and Taylor held the innings together. Guptill's last ODI hundred was against India in January 2014, so it was an important innings for the opener.

Having played out a maiden in Shakib's first over, Guptill attacked his second over, launching two sixes and a four, and continued to hit boundaries through the off-side frequently, his stand-out shot a bullet off-drive off Taskin Ahmed in the 12th over. He reached the three-figure mark in the 28th over but holed out to long-on two overs later while trying to clear Shakib.

Elliott hacked Shakib and Taijul for five fours and a six before falling to an uppish square drive, caught at sweeper cover by Taskin off Rubel. Taylor's tortured stay ended when he was trapped leg-before by Nasir Hossain, and Luke Ronchi gave Shakib his fourth wicket in the 45th over.

Anderson was the right man at the right time, hitting three straight and slog-swept sixes before missing one from Nasir in the 48th over. The late introduction of Nasir was a masterstroke and his offspin provided control from one end.

After Bangladesh were sent in, Mahmudullah struck his second successive hundred to nullify New Zealand's swing and seam threat. Brendon McCullum attacked right from the start, but Mahmudullah countered by putting together unremitting partnerships. He became the second Bangladesh batsman after Shahriar Nafees to score two ODI centuries in a row.

For the first ten overs of the match, however, Bangladesh looked like they would become the latest bit of roadkill in New Zealand's wake. Trent Boult and Tim Southee swung and seamed the ball at good pace as Imrul Kayes and Tamim Iqbal struggled to score a run. Imrul lasted 5.4 overs before Boult bowled a late outswinger to the left-hander, like a yo-yo delivered at high pace. The batsman tried to play the ball, pitching on middle and off, through the on-side and it went past his edge and ripped out his off stump.

Tamim survived Southee's inswinging yorker and an edge that dropped short of the slips, and picked up the first boundary of the innings - a clip off the pads off Boult - in the eighth over. He was dismissed two overs later, though, nicking Boult to Corey Anderson at second slip.

Mahmudullah offered two catches off the first three balls he faced, first brushing the diving Guptill's fingertips at square leg and then bursting one through Anderson's clasp at second slip. He didn't look back from that point, particularly with Southee and Boult losing movement and eventually going out of the attack

Mahmudullah preferred the off side for his fours, and seven out of his 12 came in the arc between third man and extra cover. The other five came mostly through midwicket. His three sixes were wonderful strikes - a slog-sweep, a pull over square-leg off the front foot and a final flying kiss over long on.

Mahmudullah allowed everyone to bat around him, but dominated the Bangladesh innings with big hits whenever they were needed. The best of the lot were three consecutive fours he hit immediately after completing his century, cutting past third man, crashing through the covers and dinking through square leg, making New Zealand look a little clueless for the first time in four weeks.

Ten boundaries came off the first 28 balls of the Mahmudullah-Sarkar partnership before they eased off the pedal between the 14th and 24th overs. Soumya began with two straight hits, the first a full ball dug out through mid-off. An upper cut, a carve over point and a smash through the covers followed, and after a lull for about ten overs, he tapped Mitchell McClenaghan past midwicket after jumping across to get in line of the delivery. He reached his maiden fifty off 54 balls before hitting Daniel Vettori down long-off's throat in the 28th over.

His 90-run third-wicket stand with Mahmudullah took Bangladesh out of the quicksand and into dry land. They scored at five an over comfortably, even though they went boundary-less between the 15th and 24th overs.

Mahmudullah added two more 30-plus stands with Shakib and Mushfiqur Rahim before letting Sabbir Rahman have a go at the short boundaries. Sabbir struck five fours and two sixes - a forehand smash over long-on off McClenaghan and a one-kneed clout off Grant Elliott - in his 23-ball 40.

Bangladesh's 103 from the last 10 overs was only the fifth time they had scored more than 100 runs during this phase of an ODI innings. Boult, Anderson and later Elliott - brought into the attack just to bowl the 48th and 50th overs, with Mitchell McClenaghan struggling with his follow-through in his first game of the tournament - took two wickets each.

Mohammad Isam is ESPNcricinfo's Bangladesh correspondent. @isam84