Elgar will retire from international cricket after next week’s clash in Cape Town and offered a fitting reminder of his qualities with a polished 140 not out – his first Proteas ton in nearly three years.
The 36-year-old occupied the crease for 66 overs, facing 211 deliveries and cracking 23 fours to lead his side to 256 for five. That put South Africa into a narrow lead of 11, with the tourists having earlier been bowled out for 245.
KL Rahul, resuming on 70 overnight, completed a superb century of his own as he scored 31 of his side’s 37 runs in the morning session. He was last man out, bowled by debutant Nadre Burger, having almost single-handedly kept India competitive.
With Elgar holding firm at the top of the order and captain Temba Bavuma absent with a hamstring injury, India successfully chipped away Aiden Markram, Tony de Zorzi and Keegan Petersen to leave the hosts 113 for three.
But another newcomer, Durham batter David Bedingham, helped South Africa press ahead with an elegant 56 in his maiden Test innings. He put on 131 alongside Elgar, who brought up his 14th hundred, before being cleaned up by Mohamed Siraj.
Kyle Verreyne followed as Prasidh Krishna opened his account as a Test bowler before bad light brought an early finish.
The West Indies lost the first match on Sunday by six wickets.
West Indies won the toss and sent India to bat and their bowlers justified the decision restricting India to 237-9. After Kemar Roach dismissed Rohit Sharma for five, Odean Smith backed him up with the wickets of Risbah Pant and Virat Kohli for 18 each as India slipped to 43-3 in the 12th over.
A 90-run partnership between Suryakumar Yadav and KL Rahul held the West Indies up until 30th over when Rahul was run out for 49. Yadav and Washington Sundar added 43 for the fifth wicket before Nathan Allen had the former caught behind for a well-played 64.
Akeal Hosein claimed the wicket of Sundar for 24 and India struggled to push for a more challenging score as Jason Holder dismissed Deepak Hooda for 29 and Alzarri Joseph took the wickets of Shardul Thakur for eight and Mohammed Siraj for 3 as the Indian innings closed without flourish.
Yuzvendra Chahal was unbeaten on 11.
Smith was the best of the West Indies bowlers with 2-29 while Joseph took 2-36. There was a wicket each for Holder, Hosein, Roach and Allen.
With a target that required scoring below five runs an over, the West Indies opening pair of Brandon King and Shai Hope shared in a 32-run partnership that set the visitors up for a successful chase. However, once King got out to a rising delivery from Prasidh Krishna for 18, the West Indies’ chase went off the rails.
Hope was the next to go dismissed by Chahal for 27 from 52 balls.
Shamarh Brooks contributed 44 in the middle order but he lost partners frequently as the West Indies slumped to 76-5 in the 22nd over, Krishna picking up the wickets of Darren Bravo for one and Nicholas Pooran for nine along the way.
Hosein provided some lower-order resistance for the West Indies with a stubborn 34 from 52 balls and Smith provided a late flurry to score 24 from 20 balls but the West Indies were bowled out for 193. It was the second time in as many matches that they have failed to score 200.
Krishna returned the remarkable figures of 4-12 from nine overs while Thakur took 2-41.
The final match is set for Friday, February 11.