The tourists added just 55 runs in 26.5 overs in the afternoon session to take their second innings from the lunch score of 106-1 to 161-4 by tea on the third day at the Sara Oval here on Sunday.
South Africa, seeking a series-levelling win after being thrashed by an innings and 153 runs in the first Test, lead by 201 with six wickets in hand.
Gibbs lost his concentration after a four-hour vigil under a hot sun and swept Muttiah Muralitharan to Sanath Jayasuriya at backward square leg on the stroke of tea.
Gibbs, who made 19 and 18 in the previous match and was dismissed second ball in the first innings here, fell eight runs away from his 15th century after showing glimpses of his old form.
South African captain Ashwell Prince was unbeaten on 10 at the break as the Sri Lankans appeared to regain the advantage on a dry wicket that has begun to assist turn.
Left-hander Jacques Rudolph put on 43 for the second wicket with Gibbs and was then run out for 15 amidst controversy and confusion on the field.
When Lasith Malinga's leg-before appeal against Gibbs was turned down by umpire Billy Bowden, the batsmen took off for three runs as the ball raced to the fine-leg region.
Upul Tharanga dived near the boundary to stop the ball and rifled in a direct hit to break the striker's wicket with Rudolph short of his crease.
Square-leg umpire Aleem Dar consulted television umpire Tyronne Wijewardene on whether Tharanga had fielded the ball cleanly near the boundary.
When Wijewardene ruled in favour of the fielder, he was also asked to give a verdict on the run out. Television pictures showed Rudolph well short of his crease and Dar raised his finger.
As the Sri Lankans celebrated, Rudolph stood his ground since the South African dressing room indicated Tharanga had touched the rope while fielding the ball and the umpires should award four runs.
New man Hashim Amla also ran himself out for eight when Gibbs refused his call for a sharp single and South Africa slipped from 119-1 to 131-3.
Earlier, Gibbs and Andrew Hall, who resumed on the overnight score of 6-0, saw off the Sri Lankan seamers Chaminda Vaas and Malinga in the first hour to put on 76 for the first wicket.
Hall was on 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 Muralitharan high to mid-wicket where Vaas stepped on the boundary rope after taking a running catch.
Umpires Bowden and 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.