Elgar, who came into the match with his position under scrutiny, scored 121 as he shared a second-wicket partnership of 179 with Faf du Plessis which frustrated the touring side who were the architects of their own downfall as they let numerous chances slip in the field.
Du Plessis will resume on a patient 99 along with Proteas captain Hashim Amla, who scored a double-century in the first Test in Pretoria and has reached 17.
After being sent into bat, the day belonged to left-hander Elgar, who was involved in his fourth century stand in Test cricket –- remarkably all with Du Plessis.
Following the early loss of out of form opener Alviro Petersen, caught at cover by Leon Johnson off Shannon Gabriel for 17, South Africa edged to 68 for one at lunch.
They pulled away in the afternoon session though as sloppy West Indies offered four lives to the batsmen and were made to pay for their profligacy.
Du Plessis, out for a duck in the first Test, had eight when he slashed the ball to Marlon Samuels at gully off Jerome Taylor, but was dropped.
The right-hander, on 26, was also put down at first slip off left-arm spinner Sulieman Benn and the next ball the tall West Indian was left fuming as wicketkeeper Denesh Ramdin missed a simple stumping chance after Elgar skipped down the wicket with his score on 48.
Elgar was fortunate to survive a run-out chance on 73 when he gave up halfway down the wicket having called an impossible single to mid-on and watched with relief as the throw missed the stumps.
Elgar reached his century from 208 balls in an innings that would be described more as gutsy rather than fluent, but much needed for his Test career.
He eventually fell when he edged debutant left-arm seamer Kenroy Peters to Ramdin.
The wicket showed variable bounce and took turn on the opening day, but is likely at its best for batting making the decision of the West Indies to bowl first, admittedly in overcast conditions, a brave one.
South Africa won the first Test by an innings and 220 runs.
Scorecard
D. Elgar c Ramdin b Peters 121
A. Petersen c Johnson b Gabriel 17
F. du Plessis not out 99
H. Amla not out 17
Extras (lb-4 nb-7 w-5) 16
Total (for 2 wickets, 88 overs) 270
Fall of wickets: 1-47, 2-226
Bowling: Taylor 19-4-64-0, Peters 15-6-44-1, Holder 13-5-25-0, Gabriel 15-0-52-1, Benn 25-3-81-0, Samuels 1-1-0-0.
Image: Dean Elgar celebrates after completing his century against West Indies at St. Georges Park
Photograph: Duif du Toit/Gallo Images/Getty Images
Dale Steyn rips through Windies, Proteas post huge win
Centurion Test: Amla, De Villiers share record stand to flay WI
Jayawardene, Afridi will be most experienced players at World Cup
Injured Windies pacer Roach ruled out of S Africa Tests
Philander shines as Proteas close in on victory