Moko is well known locally for playing with swimmers in the bay
Conservation officer Malcolm Smith told the BBC that he and a group of other people 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, he said.
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 he gave the dolphin a pat to say thank you
"I don't speak whale and I don't speak dolphin," Mr Smith told the BBC, "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."
He added: "The dolphin did what we had failed to do. It was all over in a matter of minutes."