The West Indies were 130 for two at lunch after being sent in to bat.
Gayle hammered 66 off 48 balls in his first innings since injuring his right hamstring against Zimbabwe 26 days ago.
Gayle and Daren Ganga put on 98 for the first wicket in just 16 overs but both were out within the space of three balls.
Ganga edged a drive at a wide ball from Andre Nel and was caught behind by Mark Boucher after making 33 off 57 deliveries with four fours.
In the next over Gayle cracked left-arm spinner Paul Harris' first ball of the match through extra cover for four but was then caught at slip by Jacques Kallis when he attempted to drive the next ball. He hit 13 boundaries.
South Africa were denied a wicket when Marlon Samuels edged Dale Steyn's fifth delivery of the last over before lunch to first slip. The South Africans celebrated and Samuels started walking but umpire Aleem Dar had called no-ball.
Gayle barely managed a jog in his pre-match fitness trial but after a discussion with coach John Dyson he took his place as captain for the first time in a Test match.
He put the injury to the test when he scored his first run with a sharp single off Steyn, having to dive to make the crease, but then played a typical Gayle innings, pounding the ball mainly off the back foot with minimal footwork to race to his half-century off 42 balls.
Both Gayle and Ganga scored boundaries off inside edges early in their innings but otherwise were seldom troubled as new ball bowlers Steyn and Makhaya Ntini both struggled to make an impression on an easy-paced pitch.