Zimbabwe were seven wickets away from their maiden Test win over Sri Lanka on Monday after setting the hosts 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 hosts.
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.
Scorecard
Zimbabwe 1st innings: 356
Sri Lanka 1st innings: 346
Zimbabwe 2nd innings (overnight 252-6):
H Masakadza lbw b Herath 7
R Chakabva b Herath 6
T Musakanda c Karunaratne b Herath 0
C Ervine c Karunaratne b Perera 5
S Williams b Herath 22
S Raza b Herath 127
P Moor c sub (Gunathilaka) b Kumara 40
M Waller c Tharanga b Perera 68
G Cremer c Karunaratne b Herath 48
D Tiripano lbw b Perera 19
C Mpofu not out 9
Extras: (B-4, LB-14, W-7, NB-1) 26
Total: (all out in 107.1 overs) 377
Fall of wickets: 1-14, 2-16, 3-17, 4-23, 5-59, 6-145, 7-289, 8-306, 9-361, 10-377
Bowling: Lakmal 14-0-43-0; Herath 39.1-5-133-6; Perera 30-2-95-3; L. Kumara 20-3-72-1; K Mendis 4-0-16-0
Sri Lanka 2nd innings (target 388 runs):
D Karunaratne b Williams 49
U Tharanga c Moor b Cremer 27
K Mendis not out 60
D Chandimal c Masakadza b Cremer 15
A Mathews not out 17
Extras: (LB-2) 2
Total: (for 3 wickets in 48 overs) 170
Fall of wickets: 1-58, 2-108, 3-133
Bowling: Raza 9-1-29-0; Williams 16-0-62-1; Cremer 19-0-67-2; Waller 4-0-10-0.
Dhawan to replace injured Vijay for Sri Lanka Tests
Afghanistan replace Australia for South Africa 'A' tour
Test vice-captain Rahane not insecure about place in ODIs
If Indian cricket requires me, I won't shy away: Thakur
Sourav Ganguly is moulded in bronze