When Misbah-ul-Haq made the mistake of thinking he could slog Dean Elgar as far as the Burj Khalifa, a resistance that threatened to ease the margin of Pakistan's loss - because avoiding defeat altogether was not a realistic possibility - seemed set to unravel. The captain left Asad Shafiq to stall South Africa's attack with the tail and even the most optimistic of Pakistan supporters predicted a swift end.
For an hour, Shafiq held defeat at bay. In the process, he notched up his highest Test score, a second century against the world's top-ranked team this year, and showed how much he has progressed as a batsman. Having impressed with the way he handled the seamers and took on the spinner with Misbah at his side, Shafiq also understood that he had to slow down, shoulder the responsibility, and only take runs when he was absolutely certain he was not putting the man on the other end, and by extension his team, in a position from which they would collapse.
When Adnan Akmal, who struggled throughout the series, was his partner, Shafiq faced Morne Morkel, letting Akmal deal with Imran Tahir. With Saeed Ajmal, Shafiq sensed a little more freedom so he allowed a few mid-over singles and even let himself show off, pulling and then driving Vernon Philander for consecutive fours.
He played with maturity towards the end, showing enough faith in Mohammed Irfan and Junaid Khan to give them the strike but not taking too many risks even though the end was nigh. It seemed as though the patience he had afforded when he batted with Younis Khan in Cape Town earlier this year, and with Misbah for much of his innings in Dubai, was paying off.
Shafiq has had the benefit of spending long periods at the crease with Pakistan's senior statesmen and he seems to have learnt from it. From the moment he came in to bat, he would have seen how Misbah was absorbing the pressure. Whether he was foxed by an Tahir googly, rattled by a Morkel bouncer, or was on the receiving end of extreme pace and angry eyes from Dale Steyn, Misbah reacted in the same way.
Misbah waited for the end of the delivery, strolled in the direction of square leg, composed himself, and came back to face the next one. He treated each ball like a chapter in a book, turning the page, leaving it behind and then carrying on with the next one.
Shafiq did not show the same composure as he neared his century and it appeared he was getting a little overexcited with his desire to charge JP Duminy. However, a calming influence in Misbah at the other end ensured that Shafiq operated within certain confines. He was encouraged to attack the short ball, something he has shown both in South Africa and during this series. He has also, simply by watching watching Misbah, learnt to judge things with caution.
In getting the balance right, Shafiq justified the selectors' decision to stick with him despite a lean run in Zimbabwe, and showed his own ability to read the game and understand a match situation. "That is a really big plus for us," Misbah said. "Everybody knows he is capable of that. He got a really good hundred in South Africa but he was a bit short of confidence coming in to this series. This innings was special because the pitch wasn't easy and the bowling was good. He really played a masterful innings."
With the South African seamers testing the batsmen with control, Shafiq's concentration was tested. So was his intent, because if he had stopped scoring runs, he could have forced himself into a corner where making a mistake was possible.
The way he responded is what impressed Misbah the most. "In situations against the top side in the world, character is important," he said. "You have to stand tall and take on the bowlers. They were using the rough very well but he was good and positive, he used his feet well and read the situation well."
Shafiq has played 23 Tests overs three years but Misbah believes it is only now that "he has started to understand the demands of Test cricket." With that kind of experience needed before a player can get out of the starting blocks, its easy to see why Misbah does not want to dispense with the likes of Khurram Manzoor and Shan Masood, who indicated they could be a solution to the opening conundrum in the first Test, but were dispatched cheaply in the second, and Azhar Ali, who is enduring a lean trot.
Pakistan had a host of problems after the first innings failure but by the end of the match, Shafiq wasn't one of them. "In the coming years you might not have me and Younis Khan around and he is the one who can gather the Pakistan line up. He has the talent and he has the temperament to take the batting forward."

Firdose Moonda is ESPNcricinfo's South Africa correspondent