Wellington: A New Zealand man has survived being attacked by a shark: driving it off with his knife, stitching his own wound onshore and going to the pub for a beer before heading to hospital.

Junior doctor James Grant was spearfishing with friends near Colac Bay at the base of the South Island on Saturday when he was attacked by what he believed was a sevengill shark.

The 24-year-old was in about two metres of murky water when he felt a tug on his leg, which he initially thought was a friend playing a trick on him.

"I looked behind to see who it was and got a bit of a shock," he told Radio New Zealand.