A controversial reprieve for Niroshan Dickwella helped Sri Lanka set a new record for a successful Test run chase in Asia and deny Zimbabwe a rare victory away from home.
The tourists had posted a challenging target of 388 at R Premadasa Stadium, where Sri Lanka resumed on day five 218 runs short of victory on 170-3.
Two quick wickets for Zimbabwe captain Graeme Cremer (4-150) in the morning session on Tuesday offered the visitors hope of recording their first away win in the longest format since beating Bangladesh in Chittagong in 2001.
But Dickwella and Asela Gunaratne combined to steady the ship, the former escaping a stumping dismissal on 37 thanks to a questionable decision by TV umpire Chettithody Shamshuddin, who deemed the batsman to have part of his back foot inside the crease despite the footage available to him suggesting otherwise.
Dickwella went on to score a career-best, match-winning knock of 81, putting on a decisive 121 for the sixth wicket alongside Gunaratne, who made an unbeaten 80.
And that partnership, together with the subsequent efforts of Dilruwan Perera (29 not out), helped the hosts to secure a four-wicket triumph.
In doing so, they surpassed not only their previous record successful run chase at the venue, where they reeled in 352 to beat South Africa in 2006, but also better the 387 chased down by India against England in Chennai in 2008 to set a new high mark for the entire region.
Sri Lanka's challenge had suffered an early blow when Cremer removed Kusal Mendis, who blundered while attempting a sweep on 66, directing a top edge to Sean Williams at mid-on.
And Cremer was gifted another scalp eight overs later. Angelo Mathews, who resigned as captain after a 3-2 defeat to Zimbabwe in the one-day international series, chipped a poor drive straight back into the arms of the bowler from an unremarkable full delivery to depart for 25.
Williams (2-146) was the man to eventually dislodge the fortunate Dickwella, a reverse-sweep attempt gloved behind to Regis Chakabva, but the breakthrough came too late for a Zimbabwe side still reeling from the left-hander's remarkable reprieve.
Gunaratne had brought up his 50 two balls earlier and, after surviving when Chakabva missed a stumping opportunity off Cremer's bowling, he continued to prosper alongside Perera, who narrowly avoided a direct hit on the stumps by the Zimbabwe skipper.
The TV umpire also cleared Gunaratne when replays showed a pull that struck Peter Moor at square leg hit the ground before ending up in the gloves of Chakabva.
Two desperate, late reviews by the visitors, for an inside edge and lbw respectively, then favoured Perera, as he and Gunaratne patiently guided Sri Lanka over the line to avoid what would have been an embarrassing home loss in the only Test of Zimbabwe's tour.