Cape Town: South African captain Graeme Smith was out for three in his last Test innings as South Africa lost three quick wickets after being set a massive 511 to win on the fourth day of the third and final Test with Australia at Newlands on Tuesday.

South Africa were 15 for three at tea but finished the day on 71 for four in front of a sparse crowd, which was a surprise after Smith's announcement on Monday that this would be his final international game and on his home ground.

Warner hit his second ton of the match yesterday. PIC/AFP

Hashim Amla and AB de Villiers defied the bowlers for more than two hours in a fourth wicket stand of 53 before Amla was leg before wicket to James Pattinson 20 minutes before the close.

Australia's declaration at 303 for five was set up by a dashing second century of the match by David Warner.

There were a potential 144 overs remaining in the match after the declaration, leaving South Africa needing to fight an extended rearguard action in order to avoid defeat.

Smith was given a guard of honour by the Australian players but soon lost Alviro Petersen, his opening partner, who was leg before wicket to Ryan Harris - the 100th Test wicket for the fast bowler.

Six balls later Smith fell for the fourth time in the series to Mitchell Johnson, edging a lifting delivery onto his thigh pad, with the ball looping to short leg Alex Doolan for an easy catch.

The Australians stood to salute Smith as he left the ground and his teammates gathered on the pavilion steps to applaud him off.

Smith kissed the badge on his helmet and waved to the crowd before disappearing into the dressing room.

It ended a poor last series for Smith, who scored only 45 runs at an average of 7.50 in the three matches.

He finished his 117-Test career with 9265 runs at an average of 48.25. He hit 27 centuries and 38 half-centuries. He was captain in a world record 109 Tests.

Dean Elgar was bowled by Johnson with what proved to be the last ball before tea.

Warner followed up his first innings 135 with 145, made off 124 balls.

His last 45 runs were scored off 32 balls before he edged Kyle Abbott to de Villiers going for another big shot. He hit 13 fours and four sixes.

When Warner was on 79 he reached 1000 runs in eight Test matches during the southern hemisphere season.

The left-handed opening batsman finished the three-match series with 543 runs at an average of 90.50, hitting three centuries and two fifties.

He scored at a strike rate of 86 runs per 100 balls, frequently forcing Smith to go on the defensive.

Warner came into the match after being fined for controversial remarks after the second Test in Port Elizabeth.

"I've been brought up to be honest," he said, although he acknowledged he needed to work on "not giving you guys ammo to write things."

But Warner said he enjoyed being in the heat of battle.

"When there's extra pressure on I do find another gear," he said.

"When I get out there and they start giving me a bit of banter I love that, I'm in a contest then. If they're not going to talk to me I will try and niggle at them."

Warner - who lost his opening partner Chris Rogers for 39 - was in sparkling form at the start of the day and reached his fifty off 41 balls with six fours and a six over long-on off off-spinner JP Duminy.

Warner and Doolan consolidated with a second wicket stand of 65 before Shane Watson and Steve Smith scored at better than a run a ball either side of Clarke's dismissal for a first-ball duck, driving to mid-off.

After the early flurry of wickets, Amla and De Villiers settled for resolute defence as South Africa sought to emulate their great escape in Adelaide in 2012/13 when they batted out 148 overs to earn an unlikely draw, having gone into the last day with four wickets down.

"There's still hope," said coach Russell Domingo. "We've got some batting to come."