The tourists were 287 for three in their second innings -- still nine runs away from an innings defeat -- when the umpires called time with only 13 overs bowled on the final day.
Mendis was unbeaten on 141 and Mathews 120 not out at stumps after a 274-run stand that, along with the weather, allowed Sri Lanka to salvage a draw.
New Zealand will view the draw as a missed opportunity after they took control of the Test with a mammoth 578 in the first innings, anchored by Tom Latham's unbeaten 264.
Latham's epic effort overhauled former England captain Alastair Cook's 244 as the highest score by an opener carrying their bat in Test history. The emphatic performance should have given the New Zealand bowlers two full days to attack a Sri Lanka line-up that showed little fight in the first innings, but Mathews and Mendis responded with a masterclass of their own.
The pair came together late on day three with Sri Lanka reeling at 13 for three in their second dig, trailing New Zealand's first inning total by 296.
They batted through the whole of day four, fending off a barrage of bouncers from the New Zealanders in a stubborn rearguard action that, along with the weather, allowed Sri Lanka to salvage a draw.
It was the only time in New Zealand that a full day's play has been completed without a Test wicket falling, and the first time anywhere since South Africa achieved the feat against Bangladesh in Chittagong in 2008.
The partnership was also a Sri Lankan record against the Black Caps.
The draw snaps a four-Test losing streak against the Black Caps on New Zealand soil.
It will give the world's sixth-ranked team some confidence after they arrived in New Zealand smarting from a 3-0 Test series whitewash against England last month.
They have also had to contend with disarray in their coaching and selection ranks.
The fourth-ranked Black Caps entered the two-match contest buoyed by their first away Test series win over Pakistan in 49 years.
They are looking for a fourth straight Test series win after also defeating England and the West Indies in the past 12 months.
The second and final Test begins on December 26 in Christchurch, where the tourists have never won in three attempts.AFP