The New Zealand skipper, who arrived to a standing ovation, peeled off one final six, pulling Josh Hazlewood into the crowd at mid wicket to reach 25 before falling next ball, to an athletic catch by David Warner at mid wicket.
That let New Zealand a parlous 108 for four but Williamson and Anderson dug deep to give some hope.
Earlier, career-best figures from aggressive left armer Neil Wagner had put a smile on New Zealand faces.
Wagner took four of the five Australian wickets to fall after lunch to finish with six for 106 off 32.1 overs to help dismiss them for 505, for an overall lead of 135 at the halfway stage of the match.
All his wickets had come from short-pitched deliveries as his tenacity was rewarded.
He was by some distance the best, most persistent of the New Zealand bowlers.
New Zealand's second innings started poorly. They lost Martin Guptill caught behind for a duck off James Pattinson to a poor defensive shot; fellow opener Tom Latham, who had got himself established on 39 before going to a legside strangle, attempting a hook and edging to wicketkeeper Peter Nevill; Henry Nicholls to a catch at second slip before McCullum's departure, to a final standing ovation.
Pattinson has taken three for 29.
New Zealand had hoped for early success at the start of the day with nightwatchman Nathan Lyon in the middle. However Lyon and Adam Voges put on 81 for the fifth wicket to push Australia well into credit.
Voges was out for 60, a comedown after centuries in his last three innings, and his dismissal brought his average down from three figures to 94.78, making him second all time behind the legendary Don Bradman.
SCOREBOARD
WAGONWHEEL
MANHATTAN