Two whale pods beached themselves in the Ohiwa harbour on the north-east coast on Monday.
Wildlife conservationists launched a rescue operation and helped one pod to be refloated on Tuesday, while 21 more whales were successfully herded out to sea on Wednesday.
The reasons for mass pilot whale strandings are not well understood.
Pilot whales are particularly prone to stranding behaviour. The largest known pilot whale stranding involved an estimated 1,000 whales at the Chatham Islands in 1918, according to the DOC.
Steve Brightwell from the DOC said the whales came into Ohiwa harbour after one of them was unwell and beached itself, reported Radio New Zealand.
Eleven of the whales were euthanized on welfare grounds on Tuesday, the Department of Conservation (DOC) said. About 25 pilot whales were found dead early Wednesday morning.