But the Proteas lost star batsman Hashim Amla for 29 and at tea were 96 for two in reply to England's first innings 458 -- a deficit of 362 runs.
Elgar was 54 not out and JP Duminy eight not out.
Both Elgar and England skipper Joe Root, who made a commanding 190 earlier Friday, were leading their respective countries in a Test for the first time.
Stuart Broad, who'd earlier frustrated South Africa with an unbeaten 57, had Test debutant Heino Kuhn out for just one when the 33-year-old opener edged to former captain Alastair Cook at first slip.
More From This Section
Elgar, however, displayed his customary resilience and it was somehow typical that he went to a 90-ball fifty with a controlled edge down to third man off all-rounder Ben Stokes -- his eighth four.
But, having been deprived of the strike, he was lbw to a sharply turning off-break from Moeen Ali.
- Morkel strikes -
==================
England resumed on 357 for five, with Root, who made the most of being missed several times to lead a recovery from 76 for four, 184 not out and Ali 61 not out.
England twice lost two wickets for no runs in three balls on Friday yet still got beyond 450, however, thanks to a rapid last-wicket stand of 45 in 27 balls between Broad and James Anderson.
Root had added just six to his overnight score when, in sight of what would have been his second Test double century at Lord's, he edged fast bowler Morne Morkel to wicket-keeper Quinton de Kock.
The 26-year-old Yorkshireman walked off to a standing ovation from a capacity and sun-drenched crowd, having batted for over six hours, facing 234 balls including 27 fours and a six.
Two balls later Liam Dawson was lbw to Morkel for a duck.
Ali, closing in on a sixth Test century, was bowled for 87 aiming a booming drive off Kagiso Rabada and tailender Mark Wood was lbw for nought.
But Broad, who made his Test-best 169 against Pakistan at Lord's in 2010, kept the runs coming with shots worthy of his father Chris, the former England opener.
He pulled Morkel for two sixes in as many balls to complete a spirited 45-ball fifty, also including seven fours.
It was Broad's first Test fifty in four years and his most fluent innings at this level since he was hit in the face by a bouncer from India's Varun Aaron at Old Trafford in 2014.
He was last man out when caught behind off Morkel, who led the Proteas' attack with four for 115 in 25.3 overs.