The Proteas, 40 runs ahead on the first innings, moved to 106-1 in their second knock by lunch on the third day at the Sara Oval here on Sunday after an absorbing contest between bat and ball.
South Africa, seeking a series-levelling win after being thrashed by an innings and 153 runs in the first Test, lead by 146 runs with nine wickets in hand.
Gibbs, who made 19 and 18 in the first Test and was dismissed second ball in the first innings here, has so far hit nine boundaries in his 22nd Test half-century.
Left-handed Jacques Rudolph was the other batsman at the crease on 11.
Gibbs and Andrew Hall, who resumed at the overnight score of 6-0, saw off the Sri Lankan seamers Chaminda Vaas and Lasith Malinga in the first hour to put on 76 for the first wicket.
Hall scored 32 when he was caught behind by wicket-keeper Prasanna Jayawardene off Farveez Maharoof while attempting a heave outside the off-stump.
Hall failed to build on the lucky break he earned on 24 when he pulled Muttiah Muralitharan high to mid-wicket where Vaas stepped on the boundary rope after taking a running catch.
Umpires Billy Bowden and Aleem Dar consulted the television umpire before ruling in the batsman's favour.
South Africa made 361 in the first innings and Sri Lanka scored 321 in reply.