Rachin Ravindra and Mark Chapman made half centuries in a 112-run second-wicket partnership which helped New Zealand to 9-255 in the second ODI against Sri Lanka.
Ravindra made 79 from 63 balls and Chapman scored 62 from 52 balls as New Zealand achieved a testing total in a match reduced to 37 overs per side because of rain.
But it was Maheesh Theekshana who stole the stage late in the Black Caps' innings, becoming the seventh Sri Lanka player to take an ODI hat-trick.
Maheesh Theekshana celebrates a hat-trick against New Zealand. Twitter
The right-arm offie dismissed Mitchell Santner, Nathan Smith and Matt Henry with consecutive deliveries across two overs on a wet pitch in Hamilton.
He received high praise from Sri Lankan great Lasith Malinga, who is the only player in ODI history to take three hat-tricks in his career.
"An outstanding spell capped off with a brilliant hat-trick," he said via X.
"Clever stuff from Theekshana."
Theekshana finished with figures of 4-44 and was the clear standout with ball in hand, while fellow spinner Wanindu Hasaranga chimed in with 2-39 from his eight over.
Showers and outfield conditions delayed the start of play by two hours, before the visitors won the toss it made the natural decision to bowl at Seddon Park.
New Zealand lost Will Young for 16 and were 1-31 when Chapman joined Ravindra in the middle, steadying the ship for the hosts.
The bowling effort was all in vain for Sri Lanka however after they were rolled for 142.