Zimbabwe were seven wickets away from their maiden Test win over Sri Lanka on Monday after setting the host a target of 388 in their one-off match at the R. Premadasa Stadium.
Sri Lanka were 170-3 in their second innings at stumps on the fourth day, still needing another 218 to beat Zimbabwe, who also recently won their maiden one-day international series against the host.
Kusal Mendis was unbeaten on 60 with Angelo Mathews, who stepped down as captain after the ODI series defeat, on 17 not out.
Zimbabwe captain Graeme Cremer picked up 2-67 in Sri Lanka's second innings to add to his five-wicket haul in the first innings.
Earlier, Sikandar Raza's first Test century helped Zimbabwe to 377 in their second innings after the touring side had resumed the fourth day on 252-6.
Raza scored 127 and added 144 for the seventh wicket with Malcolm Waller, who made 68, to ensure his side set Sri Lanka a steep target to chase.
Sri Lanka spin spearhead Rangana Herath picked up 6-116 - his 31st five-wicket haul in Tests - to total 11 wickets in the match.
356 & 377 in 107.1 overs (Raza 127, Herath 6/133) lead Sri Lanka
346 & 170/3 in 48 overs (Mendis 60, Karunaratne 49) by 218 runs