Australia faces a tough task on day four— but it’s still entirely possible

For two full days in Port Elizabeth, Australia and South Africa had wrestled inseparably. They were a pair of boa constrictors each trying to suffocate the other.

Within an hour on the third morning, one had all but swallowed its rival. Except it was the tail rather than the head doing the damage.

South Africa's overnight lead of 20 inflated to an eventual 139, as AB de Villiers marshalled his three available tailenders in an gleeful attacking flurry, scoring an unbeaten 126 for himself along the way to his team's imposing 382.

By the over after tea, that advantage had been thoroughly consolidated, with Australia still 53 adrift with four wickets gone, the major ones of Steve Smith and David Warner among them.

But if you thought that was the end of the story, you were wrong.

Through the final session, Usman Khawaja and Mitchell Marsh worked their team back out of reptilian oblivion, inch by agonising inch, and into daylight.

The deficit became neutral, then a lead, stretching to 39 and the impending safety of stumps.

Twelve balls shy came the dying day's last twist: Kagiso Rabada irresistible, Khawaja trapped for 75, and Australia left needing another lower-order escape at 180 for 5.

The thrill of de Villiers' hundred was the abiding memory of the day.

"I had a lot of intensity, almost forced myself to have that kind of intensity because that makes me get into really good positions," he said to ABC Grandstand.

"I had the bounce of the ball here and there, things went my way, and a hundred later I'm very happy."

It was an understated assessment of a batting masterclass. It had been good enough the evening before, de Villiers starting the day on 74, and the standard never dipped.

Vernon Philander was just as important in helping it happen, giving de Villiers confidence by taking a good share of the strike and cuffing the odd ball to the fence — the first three boundaries of the day were hit by the seamer.

Then AB came to the party, driving Josh Hazlewood through mid on, cutting him through point, and smacking Pat Cummins on the pull.

Before the century could be raised, Cummins speared a short ball at Philander's ribs and had the catch taken at short leg. But the same over, de Villiers calmly leant back to a short ball and produced an uppercut that nearly soared for six.

His 22nd Test hundred, and his sixth against Australia, spoke of a player of the highest quality.

"It's the biggest challenge," he said.

"In the backyard we always had games as Australia v South Africa. As a youngster growing up I always wanted to play the best, and in my mind that was Australia.

"I just feel that extra bit of magic against the Aussies."

The pixie dust rubbed off on Keshav Maharaj, who clouted two sixes from Nathan Lyon, then three fours in an over from Mitchell Starc, on his way to a fast 30.

The Australians by this point had taken to dropping the field back for de Villiers, but he toyed with their tactics, dropping the ball so softly to the deep that he had time to sprint two, then clearing the fielders who were brought up close.

So it went until Lungi Ngidi was run out by a direct hit from Steve Smith at deep midwicket. But de Villiers was unbeaten, and the damage done.

Even more so when Warner got a fast inswinger from Rabada that knocked over off stump for 13.

Khawaja came to the crease, pressure on him after three low scores and scrutiny on his poor record away from home. He responded instantly with two crisp square drives from Rabada for four.

But it didn't herald an easy innings. Khawaja had to graft. There were moments of confusion and indecision. His edge was beaten repeatedly. Other nicks found the boundary.

When he played a reverse sweep to Maharaj, the shot that saw him dismissed in Durban, it seemed to be out of cussedness. Sure, he got a boundary, but he's never been a player who likes to sweep.

In between there were moments that hinted at his top register, the batsman he can be when on song.

Cameron Bancroft shook off a blow to the stomach, made a handy 24, then unluckily played Ngidi onto his stumps in a tangle of feet and bat.

Smith fell to left-arm spin again, following a Maharaj ball that turned away from him to the wicketkeeper. Shaun Marsh nicked a wide Rabada ball just after tea. It was 4 for 86.

But Khawaja was driving the spinner through cover, cutting Philander, raising a half-century that was as welcome for his own career as for the team.

Mitchell Marsh defended cautiously to 5 from 39 balls, then crashed Ngidi over the midwicket fence when the bowler dropped short. His cut shots were as brutal.

The partnership grew. South Africa grew twitchy. Both their reviews were burned on speculative calls. Khawaja barely cleared mid-off, edged another couple of balls, but survived and sometimes prospered.

Until Rabada. With the partnership at 87, and the bowler's hearing for his potential suspension looming, South Africa's attack leader found a last bit of swing.

Marsh and Tim Paine will return, 41 runs to the good, with a mighty job to do between them and Australia's bowlers. They've done it before, all of one Test match ago in Durban.

It shouldn't happen again. But you'd scarcely dare bet against it. This enthralling match has given adequate caution as to why.