Conservation officer Malcolm Smith and volunteers had tried in vain for an hour and a half to get the whales to sea.
The pygmy sperm whales had repeatedly beached, and both they and the humans were tired and set to give up, reports the BBC.
But then the dolphin appeared, communicated with the whales, and led them to safety.
The bottlenose dolphin, called Moko by local residents, is well known for playing with swimmers off Mahia beach on the east coast of the North Island.
Mr Smith said: "I don't speak whale and I don't speak dolphin but there was obviously something that went on because the two whales changed their attitude from being quite distressed to following the dolphin quite willingly and directly along the beach and straight out to sea."
Mr Smith said he felt fortunate to have witnessed the rescue, and was delighted for the whales, as in the past he has had to put down animals which have become beached.
The whales had not been seen since, but the dolphin had returned to its usual practice of playing with swimmers in the bay.
"I shouldn't do this I know, we are meant to remain scientific," Mr Smith said, "but I actually went into the water with the dolphin and gave it a pat afterwards because she really did save the day." (BBC)