The left-handed pair put on their nation’s highest partnership for any wicket as Bangladesh, trailing by 296 runs on the first innings, closed the day on 273-0 in their second knock.
Tamim was unbeaten on 138 to become the first Bangladesh batsman to score seven Test centuries. He beat former captain Mohammad Ashraful’s tally of six.
It was Tamim’s third century in as many Tests, having made identical scores of 109 in the last two matches against Zimbabwe in November.
Imrul scored 132 not out, his third hundred, as the bowlers toiled on the placid wicket at the Sheikh Abu Naser Stadium that has already produced 1,233 runs and just 20 wickets over the four days.
The pair batted through just over two sessions to surpass the previous Bangladesh record of 267 by Ashraful and current skipper Mushfiqur Rahim for the fifth wicket against Sri Lanka in Galle in 2013.
Tamim said the advice from his team’s Sri Lankan coach Chandika Hathurusinghe to forget the scoreboard and enjoy the time out in the middle stood both him and Imrul in good stead.
“The coach told us not to look at the scoreboard and that helped,” he said. “We just wanted to enjoy the game and when we got a ball to hit, we played our shots.”
Tamim and Imrul had put on an opening stand of 224 during Bangladesh’s previous Test – against Zimbabwe in Chittagong – and carried on in the same manner.
Fears that Bangladesh may struggle to bat out two days to save the match, after Pakistan ran up 628 in their first innings, proved unfounded as the openers settled in to tame the bowling.
Tamim reached his century after tea with two consecutive boundaries off Junaid Khan. Imrul swept Zulfiqar Babar for a single soon after to bring up his own landmark in front of some 5,000 delighted home fans.
Tamim has so far hit 13 boundaries and four sixes. Imrul has 15 fours and three sixes.
Earlier, the tourists took their overnight score of 537-5 to 628 before they were all out shortly before lunch.
The overnight pair of Asad Shafiq (83) and Sarfraz Ahmed (82) carried their sixth-wicket partnership to 126 to build a sizeable lead for Pakistan.
Left-arm spinner Taijul Islam picked up three of the five wickets in the morning session to finish with figures of 6-163.
Shafiq said Pakistan were confident the Test could still be won.
“The first session tomorrow will be important,” he said. “We are still in the game and two or three wickets quickly in the morning will help us press for victory.
“The wicket is playing well and both Tamim and Imrul batted really well. But the complexion of the game can change if wickets come our way.”
The second and final Test begins at the Sher-e-Bangla Stadium in Dhaka on May 6.