KANPUR, India (AP) — India survived a thrilling run chase by New Zealand to win the third ODI by six runs on Sunday and clinch the three-match series 2-1.

Chasing 338, the Black Caps rode on half-centuries from Colin Munro (75), Kane Williamson (64) and Tom Latham (65) before falling agonizingly short.

This was after Virat Kohli (113) struck his 32nd ODI hundred and put on 230 runs for the second wicket with Rohit Sharma (147) as India scored 337-6. In reply, the visitors finished at 331-7 in 50 overs.

"The aim is always to help the team win games, regardless of how many runs I score," Kohli said.

India won its seventh straight bilateral ODI series.

New Zealand got off to a bright start as Munro and Martin Guptill put on 44 runs off just 26 balls. Jasprit Bumrah (3-47) then dismissed Guptill. Munro and Williamson added 109 runs for the second wicket and New Zealand crossed 100 in the 15th over.

Munro reached his fifth ODI half-century off 38 balls, while Williamson scored his 33rd ODI 50 off 59 balls. Their 100 partnership came off 109 balls.

Yuzvendra Chahal (2-47) got the big breakthrough as Munro misread a slow delivery turning in and was bowled in the 25th over. Ross Taylor (39) kept the chase going and quickly put on 50 runs off 40 balls for the third wicket with Williamson.

Chahal struck a second big blow as Williamson skied a shot and keeper MS Dhoni completed the easy catch. New Zealand were 168-3 at that time but still in the driver's seat.

Latham then made good on his run of form and put on 79 runs with Taylor as the visitors passed 200 in the 34th over. Bumrah got the breakthrough as Taylor was caught at point in the 41st over.

Henry Nicholls (37) put on 59 runs with Latham for the fifth wicket. The latter brought up his 10th ODI half-century off 37 balls.

New Zealand crossed 300 in the 46th over and set up a tense finish. But it lost too many wickets in the death overs as Bhuvneshwar Kumar and Bumrah squeezed them for runs.

Kumar bowled Nicholls, while Latham was run out after a mix-up with Colin de Grandhomme (8 not out).

The Black Caps needed 15 off the last over to win its first-ever ODI series on Indian soil, and it proved too much.

It was the fourth-closest margin of victory by runs in ODIs between India and New Zealand.

Earlier, Kohli scored 113 runs off 106 balls, with nine fours and a six. In doing so, he also crossed the 9,000-run mark in ODI cricket. Sharma scored 147 runs off 138 balls, including 18 fours and 2 sixes, for his 15th ODI hundred.

Kohli was awarded the man of the series for his two hundreds in Mumbai and Kanpur. Sharma was man of the match.

Put into bat, India lost Shikhar Dhawan (14) early, out caught off Tim Southee (2-66) at mid-off. Sharma and Kohli then came together and took India past 50 in the 10th over.

Sharma attacked the bowling more than his partner and reached his half-century off 52 balls. India's 100 came up in the 19th over as the duo put on 100 runs off 106 balls.

Kohli reached his half-century off 59 balls. In his 194th innings, he became the quickest batsman to achieve the 9,000-run milestone, going past AB de Villiers' 205 innings for South Africa.

Sharma reached his hundred off 106 balls and he and Kohli brought up their 200 partnership off 187 balls. It was the fourth instance of the duo putting on a 200-plus partnership in ODI cricket, the highest number for any pair of batsmen. Kohli then reached his hundred off 96 balls.

Sharma was caught in the deep off Mitchell Santner (2-58).

Kohli became Southee's second wicket of the day, out caught at long off.

"Coming to this game, and coming so close is frustrating, but there are very good signs overall," Williamson said. "Our middle order is shaping up well. The bowlers performed well in most games. At the end of the day, India played better cricket."