The game threatened to slip away in Galle too, when Milan Rathnayake and Kamindu Mendis added 84 for the seventh wicket. But offspinner Nayeem's first five-for in an overseas Test helped dismiss Sri Lanka for 485 and gave Bangladesh a ten-run lead. Shadman then gave their second innings stability, which Bangladesh have often lacked, with an innings of 76.
It left them 187 in front with seven wickets in hand going into the fifth day. All results are possible, uncommon in a Sri Lanka-Bangladesh contest which are mostly one-sided. Bangladesh need several players to step up for a Test win, rather than individual heroics, like they did in Pakistan and West Indies last year. Shadman and Nayeem's meaningful contributions has given them a chance on the final day in Galle.
Nayeem, playing in place of the ill Mehidy Hasan Miraz, bowled more than 40 overs, creating more chances than Taijul Islam. He had Dinesh Chandimal caught at leg slip on the third afternoon, before dismissing Dhananjaya de Silva in similar fashion early on the fourth day.
Nayeem switched sides several times, going around to the wicket to the right-handers. He stayed around the wicket to the left-handers and bowled his best ball of the day: a cracking offbreak to Mendis that dipped in front of him and kissed the outside edge to have him caught behind on 87. It swung the momentum Bangladesh's way on the fourth afternoon.
"I think I bowled a great delivery to him. It was also great to remove three right-handed batters," Nayeem said. He did Bangladesh a huge favour by wrapping up the tail quickly, which they have struggled to do in the past.
"I tried to bowl in one good spot and then adjust my variation there. I tried changing the seam position from time to time. My line depended on who I was bowling to. I had different plans for each batter.
"It was a batting-friendly wicket so we tried to bowl consistently in one area. When you cut off the runs, the batter gets into pressure. He tries to do something different, which can lead to a mistake."
Nayeem praised Bangladesh's batters for taking the game forward on the fourth day. "I think only those who batted in the middle, know what it is like. Shadman bhai batted really well. Mushy bhai and Shanto bhai are also doing well. It is all going well."
Shadman looked comfortable from the start of Bangladesh's second innings, in contrast to his opening partner Anamul Haque. He had just made a comeback in Bangladesh's previous Test, against Zimbabwe, after being passed over by the selectors for Zakir Hasan and Mahmudul Hasan Joy.
Zakir and Mahmudul lost their places after underperforming for at least a year. Anamul was a popular choice in April after scoring a string of centuries in the Dhaka Premier League List-A competition. Anamul had good numbers in the domestic first-class tournaments too, but his return already seems like another false dawn in a long career.
Many blame the poor quality of Bangladesh's first-class competition for boosting Anamul's numbers but it is the same tournaments in which Nayeem and Shadman have also performed.
Nayeem has taken 38 wickets at 25.89 in ten matches in the last 12 months, while Anamul made 862 runs at 41.04 in the same period. Nayeem has only played 13 out of 43 Tests since his debut in November 2018, but he has been a domestic giant, taking 176 wickets at 22.64 apiece with 12 five-fors. Anamul is the batting equivalent, scoring more than 6000 runs at 46.46 with 17 first-class centuries.
Nayeem and Anamul are usually picked by Bangladesh when there's an injury or as a last resort. Nayeem has always grabbed those chances, having taken the fourth most wickets in the team since his debut. Anamul, however, hasn't converted his domestic form into international runs, with many now ridiculing his strong social media presence as being an influence on the selectors.
Nayeem said playing so much domestic cricket had prepared him for the toil in Galle. "We have to bowl well for a long time in our first-class cricket. We sometimes get help from the pitches. We got a great pitch here. Field placings then also become important. Wickets here only come after you have bowled a long time on a consistent line and length."
After the fourth day's play, Nayeem was asked whether he considers himself unfortunate to have played only 13 Tests since his debut in 2018. "I don't consider myself unlucky. Allah provides sustenance. Not everyone's career will be the same. I am happy with what I got. Thanks to Allah, I could make use of the opportunity."
Given how the fourth day panned out in Galle, Bangladesh can thank cricketers like Nayeem and Shadman, who spend much of the year waiting for opportunities, for keeping their chances of victory alive.