Faf du Plessis needed a hundred. He didn't want it, he needed it.

After coming back from a broken finger to captain South Africa in this series, with no game time and a month on the sidelines, du Plessis insisted he was mentally ready for the challenge but the numbers said otherwise. He averaged 11 from the first three Tests and was plucked for a first-ball duck in the first innings here at the Wanderers. He needed a hundred.

And the situation was such that he could get one. Du Plessis came in to bat late on the third afternoon, with his team well ahead and the pressure pretty much completely off. For du Plessis, whose team does not need to win this game to clinch the series, the consideration was a runs versus time equation. How much time did he need to give his attack - of which only the spinner was fully fit - to bowl Australia out? And how many runs did he need to be absolutely sure Australia could not reach the target in that time? And maybe he would have thought of how many runs he might be able to score as well.

Especially when he was hit on the same finger that broke in February. Twice.

Chadd Sayers struck du Plessis on that finger on the third evening, when a length ball reared up to miss the flick and du Plessis chucked the bat away in surprise. Five balls later, he hit Sayers over his head for four and three balls after that, pulled him in front of square for four more.

But the real test came on the fourth morning, when Pat Cummins, bowling substantially quicker than Sayers, got one to lift and find the same finger. When du Plessis removed his glove, his finger was swollen and bloodied. He required lengthy on-field treatment and the reapplication of the protective padding he has had around his finger for the most of the series, that he went without in this innings until there was no choice.

Some other player - one who knew he didn't actually need to bat on or one who might be thinking about an injured finger and an IPL contract - might have walked off the field at the moment. Not du Plessis.

"That would have motivated him more, made him hungrier to stay out there and fight through the pain. That's his character when he's batting," Dean Elgar, who was at the other end said. "It was not nice for him to get hit on that finger twice. Once you've hurt something, you seem to keep hurting it if you don't have time off from the game. It was nice to see him solider on, that's what leaders do and I never expected him to do anything else."

Du Plessis was on 43 off 91 balls when he was hit. He went on to score 57 runs off his next 72 balls, including powerful sweeps one of which went for six off the top-edge, extravagant shots down the ground and an outside edge to bring up his eighth Test hundred and provide reassurance over his form.

Du Plessis has made a habit out of getting to a point where questions are starting to sprout about his form and then he answers with a big score. In Australia 18 months ago, he came back from scores of 37, 32 and 7 in the first two Tests, and a conviction of ball-tampering, to score an unbeaten 118 in the day-night Test in Adelaide.

Since then, he only has one other triple-figure score from five series to his name before Monday: 135* against a hapless Bangladesh at the start of this home summer.

Having the captain contributing always makes a difference, which is why du Plessis needed the hundred more than he wanted it. "When he is playing well and the rest of our batting unit is playing well, I am smiling," Elgar said. "Test cricket is such a ruthless environment that when you are out of form it can chip away at you and it can put you in a dark place. But you are only ever one knock from being back in form, that's the funny thing about professional cricket. He showed a lot of toughness and grit. He's the happiest out of anyone in our changeroom."

Elgar didn't need a hundred because he already has a big one in this series but he still might have wanted it.

He has, after all, seen more balls than anyone else in this series, so if anyone should have more runs, it is him. In four Tests, Elgar has faced 858 balls, over 100 more than his nearest competitor Aiden Markram (754) and more than twice what the nearest Australian, Tim Paine (426 balls) has seen.

There is no greater proof of Elgar's patience and resolve than his statistics from his half-century in the second innings at the Wanderers. The fifty came up in 199 balls, a strike rate of a shave over 25%, but of those 180 were dot balls. Elgar played just 19 scoring shots in his half-century.

He finished with 81 runs from 250 balls, with 215 dot balls and only 35 scoring shots. To show that much restraint for more than five-and-half hours takes discipline and fine temperament. Elgar has proved over the course of the last year that he is stubborn and strong-willed, two of the qualities every opener needs, and he showed them here.

"With so much time left in the game I knew that was ultimately my job to try and anchor the innings. I think it was important for someone to drive it home by spending some time at the crease," Elgar said. "It comes down to trying to nail the basics of batting and just trying to be hungry out there and a lot of discipline with regards to defence."

Most pleasing for Elgar was the way he dealt with Nathan Lyon, who bowled 135 balls to Elgar and dismissed him. Elgar scored 24 runs off Lyon and though he conceded Lyon had "the edge" over him, he described the contest between them as "brilliant."

"Facing Nathan Lyon bowling at 96 kph on a wicket that is very unfamiliar to Wanderers wasn't very easy," Elgar stated. "Strike rotation was quite tough and I just had to adopt a very simple gameplan. I thought if my defence was very good against him I could negate most of the balls that he threw my way and I knew that the right-handers would be able to score off him. I can't wait for the next one. It's a battle between two guys who are highly competitive. He has had the edge over me but I know he has also bowled a hell of a lot of balls at me and I've frustrated him. He's someone I know I'll have a beer with afterwards."

So Elgar didn't get the hundred he wanted but he did get something else. He took his 50th Test catch to end the Australian innings, diving full length after running back from mid-off and though the scorecard won't show it, it's Elgar's moment of the last month. "The catch is the highlight of the series for me. Leave the runs, those catches never happen. I thought, 'Just catch it because the bowlers are hurting. They don't want to bowl anymore'. The ball got away from me a little bit towards the end and I had to put in a big dive. The rest is history."

And soon, the series will be too and in all likelihood it will end with South Africa making history - with a first series win over Australia since readmission - and with du Plessis and Elgar getting what they want and what they need.

Firdose Moonda is ESPNcricinfo's South Africa correspondent