"I just wanted to go out and hit most of the climbs hard. I did that but hit a flat spot mid-race and felt a bit sick.
"I came good though and for the last two laps of the race I felt really strong, although it was still really close and could have gone either way.
"But I was able to capitalise on a small fumble by Sam and stretched out a good advantage and pinned the ears back to the finish."
The result was a reversal of last year's race when Gaze triumphed in a sprint finish over Cooper.
Meanwhile, 27-year-old Kate Fluker from Queenstown, who rides for the Rotorua-based NZXC Racing team, put in a dominant ride to retain her elite women's crown.
When her main rival, Olympian Karen Hanlen, had a fall on the first lap, Fluker was able to build a big lead.
Rotorua's Amber Johnston finished third and first in the under-23 women's class.
Rotorua's Connor Johnston, Amber's younger brother, also won a national title in the U15 boys division.
- Results:
Men: Elite and Under-23: Anton Cooper (North Canterbury) 1:30:40, 1; Sam Gaze (Cambridge) 1:31:50, 2; Dirk Peters (Rotorua) 1:33:51 3; Ben Oliver (Christchurch) 1:35:32, 4; Jack Compton (Wellington) 1:35:49, 5.
Women: Elite and Under-23: Kate Fluker (Queenstown) 1:30:59, 1; Karen Hanlen (Whakatane) 1:34:08, 2; Amber Johnston (Rotorua) 1:37:14, 3; Fiona Macdermid (Palmerston North) 1:38:32, 4; Mary Gray (Dunedin) 1:40:14, 5.