The South Africans, needing 588 runs to avoid an innings defeat, lost three top batsmen for 20 in the post-lunch session before ending the fourth day's play on 311-4 in their second innings on Sunday.
The South Africans put on a better display in contrast to the opening day blues when they were shot out for 169, but still need to bat out a minimum of 90 overs on the final day Monday to save the game.
The hosts will need six wickets on the fifth-wicket track at the Sinhalese Sports Club to take the lead in the two-match series.
South Africa's hopes of extending Sri Lanka rest on Prince, who shared an unbroken fifth-wicket stand of 77 with Mark Boucher (38 not out) after the tourists were reduced to 234-4.
Left-handed Prince, who took over the leadership from the injured Graeme Smith, hung on doggedly for three hours and 24 minutes to score his second Test half-century with the help of four boundaries.
Herschelle Gibbs, due to come in next after recovering from a stomach bug, is the last specialist batsman in the pavilion.
Andrew Hall, who put on 165 for the first wicket with Jacques Rudolph (90), was confident the Proteas can wriggle out of the tight situation.
"We are positive and have done well so far, I think it can be done," said Hall. "We are not a side to give up easily. This game is not over yet."
Sri Lankan coach Tom Moody blamed the slow wicket for his side's inability to run through the opposition a second time.
"Ideally a wicket should help the spinners on the last three days, but this one is playing as true as ever," the Australian said. "The bowlers have to really work hard for the wickets.
"We knew South Africa would come back hard in the second innings, but we have the bowlers to do the job tomorrow."
The pace-spin duo of Dilhara Fernando and Muttiah Muralitharan, who bagged four wickets each in the first innings, once again shared the spoils after South Africa made a promising start.
Makeshift openers Rudolph and Hall put on South Africa's best ever stand for the first wicket against Sri Lanka. But Fernando struck 35 minutes after lunch.
The tall seamer, playing on his club ground, forced a well-set Rudolph to edge a catch to Chamara Kapugedera at third slip and then trapped new man Hashim Amla leg-before.
Off-spinner Muralitharan ended Hall's defiance by claiming him leg-before for 64 just before tea as South Africa lost three quick wickets in the afternoon session.
Muralitharan returned after tea to trap A.B. de Villiers leg-before for 24 as the batsman, who had publicly announced his intention before the series to attack the spinner, attempted to sweep a flighted ball.
Sri Lanka had piled up 756-5 declared in their first innings, with captain Mahela Jayawardene making the fourth highest Test score of 374 after sharing a world record partnership of 624 with Kumar Sangakkara (287).
The batting feast came after South Africa were dismissed for their lowest total against Sri Lanka on the opening day.