Malinga returned career-best figures of 5-6 to bundle New Zealand, who won the series 2-1, for 88 while chasing 126 in Kandy.
The 36-year-old then cleaned up Colin de Grandhomme, for 44, to achieve the feat in his 74th T20 match of his illustrious career.
Victory was achieved with an hour left on day five when Lasith Embuldeniya edged a short delivery from Trent Boult to Kane Williamson at gully.
Tom Latham, on 55, and Henry Nicholls, on five, were batting at the break with New Zealand still trailing the hosts by 141 runs.
Veteran spinner Dilruwan Perera comes in for Akila Dananjaya, who was reported for a suspect action for the second time in 10 months.
Williamson, 29, bowled just three overs during the second innings of the game which Sri Lanka won by six wickets.
Regular skipper Kane Williamson and paceman Trent Boult will be returning home for a pre-planned rest following the current Test series, which Sri Lanka are currently leading 1-0.
Karunaratne enjoyed some luck on the way to his century, dropped on 58 at forward short leg by Tom Latham while wicketkeeper BJ Watling missed a stumping chance on the same score.
Wicketkeeper B.J. Watling, who had stitched a 54-run stand with Tim Southee for the seventh wicket on day three, added 46 runs for the eighth wicket with William Somerville.
Suranga Lakmal shared the new ball with off-spinner Akila Dananjaya, who was preferred over seamer Lahiru Kumara.
Ross Taylor went for 86 on his first delivery of the day as he attempted a casual cut shot to a harmless delivery from seamer Suranga Lakmal and was caught behind.
Dananjaya, bowling with a remodelled action after being reported for a suspect action last year, stood out with his fourth five-wicket haul.