Long before Tamim Iqbal's fourth-innings classic, before Mustafizur Rahman magicked Bangladesh into the match, two senior batsmen had forged an important resistance.
At one end, Mushfiqur Rahim: he of the chequered 2016, premature World T20 celebrator, gloating tweeter, captain, and emotion machine. At the other end, Shakib Al Hasan, occasionally preening Bangladeshi superstar, recent purveyor of overambitious shots.
They had come together after a Sri Lanka surge. Three wickets had fallen for six runs, and Bangladesh were still 169 runs short of Sri Lanka's target. The hosts had begun to wrap their tentacles around the match, and Bangladesh needed this pair to lean on their combined 103-Test experience, and put up a fight. After a few early jitters, they did.
It was calculation and sensibility that defined their 92-run stand. Shakib may have been reckless in the first eight balls of his innings, but he had sobered up overnight, venturing boundaries only off the truly bad balls; choosing to mine the gaps off most of the others. Mushfiqur Rahim, in a rich vein of 2017 form, seemed secure at the crease, gathering runs like fallen fruit into a basket, easing singles, pushing gentle twos.
It was a vital passage of play: Sri Lanka could so quickly have sewn up Bangladesh's innings, and very nearly locked the visitors out of the match. Instead, the momentum stood shifted. When debutant Mosaddek Hossain walked to the crease, he did so with Bangladesh less than 50 runs from the lead.
"What made me happy was how we understood the value of the match even when we were ahead or behind in the game," Mushfiqur said after the match. "We tried to recognize small things can add up to something big in the end. The batsmen and bowlers played with responsibility."
While Mushfiqur managed only a half-century, Shakib would go on to 116. Both men also left their mark on the second innings. Shakib with his bowling, shouldering the responsibility of applying pressure while Mustafizur delivered an outstanding post-lunch fourth-day spell at the other end. Skidding some balls on, and turning others, he wangled out the wicket of Asela Gunaratne, then later, turning one out of the rough, took the prize scalp of Dimuth Karunaratne. Bangladesh coach Chandika Hathurusingha had suggested Shakib was no longer the bowler of old, but in figures of 4 for 74, he captured a little of his old self.
Mushfiqur had contributed to those figures, moving to the leg side in anticipation of a paddle-sweep from Niroshan Dickwella, then pouching the catch, but it was Bangladesh's chase that saw his best second-innings contribution. There had been a slight wobble in the innings when Sabbir Rahman and Tamim fell within four overs of each other, but Mushfiqur becalmed the innings - alongside Shakib for a 19-run stand - and kept the team on track.
"I have never faced such a situation in Test cricket - it is new for us to chase in this type of wicket on a fifth day," Mushfiqur said. "Tamim and Sabbir really made it easy for us with their 100-plus stand. But no opposition would let us have it easy. We had the belief in the end stages, though unfortunately we lost Shakib. We had Mosaddek and Mehedi Hasan and we thought we could do it in singles."
Mushfiqur had been unable to guide his team to safety in Wellington, where he was hit on the head and taken away in an ambulance. He couldn't bat enough time in Hyderabad, where he was conned into giving away his wicket by R Ashwin. Most famously, in that T20 match in Bengaluru, he'd lost his cool with a win within his grasp, and the team went on to lose the match.
Here, where he and Shakib had wrestled the match back from Sri Lanka. Mushfiqur was here at the end. This time, the arms were raised in celebration only after Bangladesh had won.
Andrew Fidel Fernando is ESPNcricinfo's Sri Lanka correspondent. @andrewffernando