Batting on a placid University Oval wicket, the pair put on 231 for the first wicket before Cook was out for 116 while Compton posted his maiden Test century to be not out 102.
At stumps, England were 234 for one, 59 runs short of making New Zealand bat again with only one day remaining in the rain-interrupted Test.
After facing 252 deliveries in more than five-and-a-half hours, Cook was dismissed 14 balls before stumps when he edged Trent Boult to wicketkeeper BJ Watling.
New Zealand had declared their first innings at 460 for nine in the morning session on Saturday, a comprehensive 293 runs ahead of England’s first innings 167.
But their bowlers were unable to reproduce their first innings domination as Cook and Compton cruised through most of the day.
Compton had a scare on 16 when New Zealand appealed for a catch down the leg-side but both the appeal and review were turned down, and both Cook and Compton narrowly made their ground taking cheeky singles late in the day.
But other than that their innings were chanceless — easily countering what swing Neil Wagner could muster on the same wicket where he bagged four first innings wickets — until Cook fell just before stumps.
Until then, Cook and Compton’s resistance had been formidable and without fanfare with Compton showing no sign of the pressure he was under to retain his place in the side after a four-ball duck in the first innings.
He could not disguise his delight as he jumped in the air and pumped his fists after flicking Tim Southee to midwicket to bring up his hundred knowing he had played a vital role in getting England out of trouble and probably saving his Test career.
England’s measured approach was in contrast to the New Zealand onslaught when they resumed the day at 402 for seven and declared at 460 for nine.
In a whirlwind opening session, they cracked 58 runs in less than nine overs as Brendon McCullum raced from 44 to 74 and Bruce Martin advanced from 17 to 41.
McCullum declared after the dismissal of the overnight pair to give his bowlers more than an hour before lunch to attack the England line-up.
But with conditions weighted heavily in favour of the batsmen, the bowlers struggled to make an impact and a draw was looming as the likely outcome.