(Adds details to close)
NOTTINGHAM, England, July 14 (Reuters) - South Africa lost four wickets in the final session of a fluctuating first day of the second test against England at Trent Bridge on Friday but finished with a defiant flourish to end on 309 for six.
Heavily beaten in the first test, where spinners Moeen Ali and Liam Dawson took 14 wickets between them, the tourists had to battle swing and seam this time. Pacemen took all six wickets, Stuart Broad picking up three on his home ground.
Morning cloud cover meant that deciding to bat first after winning the toss was "a tricky decision" according to returning captain Faf du Plessis.
By tea, a score of 142 for two appeared to have justified his choice but after a century stand by Hashim Amla, passing 8,000 test runs, and Quinton de Kock, both were dismissed in the first six overs after the interval.
Ben Stokes then snapped up two quick wickets but Vernon Philander, with an unbeaten 54, and Chris Morris (23 not out) carried the tourists past 300 without further damage.
James Anderson became the first man to take test 300 wickets in England when he had opener Dean Elgar brilliantly caught at backward point by a diving Dawson for six.
Anderson has always enjoyed Trent Bridge, where he took 7-43 against New Zealand in 2008 and 11 wickets against Pakistan two years later. So has Broad, taking 8-15 as Australia were dismissed for 60 two years ago.
Broad claimed the second wicket, bowling opener Heino Kuhn off an inside edge without adding to his lunch score of 34.
Kuhn had earlier been struck two painful blows by Broad and Mark Wood, one on the hand and one on the back of the helmet, before being given a brief respite with a 20-minute break for rain.
In brighter afternoon weather Amla and De Kock took the game to the hosts as they put on 113 in 25 overs.
Alastair Cook dropped a sharp chance at slip with Amla on 56 but to the first ball after tea the former captain snapped up De Kock off Broad for a lively 68 from 81 balls.
That was 179 for three and 15 runs later Broad's bouncer tempted Amla, on 78, into hooking to deep square leg where Wood took the catch.
Du Plessis had made only 19 when he was superbly caught behind one-handed by Jonny Bairstow from the merest touch off his glove, giving Stokes a first wicket.
The same combination accounted for Temba Bavuma, who had made 20 but Philander and Morris offered South Africa every hope of at least a par score of 350.
Reporting by Steve Tongue, editing by Ed Osmond