With half an hour to go on the third day at Newlands, field placements and bowling strategies meant South Africa's seventh home series win on the trot was almost in the bag. But after a bizarre unraveling at the tail end of the day, the hosts will now have to return on the fourth morning to knock off the 41 runs needed to finally seal the series.
"Nothing like that has ever happened," a somewhat bemused Kagiso Rabada said after the borderline farcical end to the day. "We were in a rush. Dale [Steyn] was bowling off a quarter run-up, and then the dramatic no-ball. And then after all of that to happen, we decide not to go out and bat."
With Pakistan nine down and the extra half hour still an option, it was all going swimmingly for South Africa until Vernon Philander's heel ruined what could have been the penultimate part of the Faf du Plessis' grand plan, and the game descended into the sort of nonsense that only cricket is properly capable of.
The umpires spotted the no-ball after Mohammad Abbas, who had been caught slogging high to mid off, had already left the field, as had Quinton de Kock, who would have opened the batting in pursuit of quick runs. Everyone had to be called back on, de Kock looking supremely peeved as he charged back down the stairs, and Shaheen Shah Afridi added to the surreal atmosphere by lifting Steyn cleanly back over his head in the same over during which he was dropped at deep midwicket and pinged on the front of his helmet by a short one.
Rabada returned to have Afridi caught at midwicket, but in a moment of peak cricket, the umpires then called stumps - with the light perfect (and good for at least another hour), both teams keen to get on with things, and a packed stadium looking on.
"The captain and the coach made the decision," Rabada explained . "They felt that trying to bat five overs and getting 41 runs is not worth it, so we'll just come tomorrow and knock them off."
The ending ruined what had been a day of toil in the field for South Africa, but one during which they had shown exceptional resilience and stuck to their plans. In the first innings, Duanne Olivier had once again bullied the batsmen with his bumpers, the short ball generally ringing out anxiety, rather than authority, from the visiting batsmen as they folded for 177, their lowest total of the tour so far.
But when the same tactic did not work the second time around on a pitch made benign by three days of baking sunshine, with Asad Shafiq and Shan Masood pulling and cutting fluently, the plan became to stick to a channel and simply outlast the opposition. And Pakistan blinked first.
"Even though the run rate shot up and Asad Shafiq started playing shots and scoring quickly, that's where we needed to show the resilience," Rabada said . "We needed to outlast them. Not breaking, and waiting for that breakthrough. Once it came, we were back in the game. It's very hard to get in on this wicket, and that's something Faf kept reminding us about.
"We had to show a lot of resilience, but that's Test cricket. We toiled. Today was a toiling day, but it wouldn't be Test cricket if it was too easy. What's important is that we showed resilience."
While his bowlers did an excellent job of sticking to a plan, Du Plessis' ability to plot and pull off a scheme was perfectly distilled in the dismissal of Yasir Shah, caught by substitute fielder Zubayr Hamza at a long stop position directly behind de Kock. Indeed, du Plessis had foretold Hamza's catch in prescient fashion before this Test had even started.
"I'm looking forward to him coming on to the field as 12th man and getting one of those high ones that just test you as a youngster, just to see where you are with a bit of swirl in the wind here in Cape Town," du Plessis said of Hamza. "Hopefully he takes it. He's a good fielder."
He did, and the plan worked perfectly. When Yasir fell, Pakistan were eight down and still seven runs shy of making South Africa bat again. Rabada returned to have Babar Azam caught at slip, and Philander then pulled off the coup de grace - almost. Had Philander kept his heel behind the line, South Africa would in all likelihood have chased down the necessary runs this evening. The no-ball meant that South Africa had to revert to plan B, and everyone will have to come back tomorrow, but despite the wobble, home remains a fortress for South Africa - and that's an important part of South Africa's more long-term plans.
"Faf mentioned before we started this series that yes we want to win every single game, but at home we want to be unbeaten," said Rabada. "It's something that we want to take forward. Ultimately, our goal is to be the number one team in the world. We want to make this a fortress. So far so good. But we also want to win overseas. It's what the past players have done, not losing overseas for such a long time, and it's something we want too."