But the return of Batty, who had been ignored for much of the afternoon, did for Rahim, well caught by Gary Ballance in the leg trap for 39, before Broad steamed in to get rid of Mehedi Hasan and Kamrul Islam Rabbi.
And England might even have completed victory before bad light brought a premature close had Joe Root clung on to a sharp slip catch after Batty had found the edge of No 10 Taijul Islam.
Instead, both sides will return on Monday to complete a game that has been a wonderful advert for Test cricket in this part of the world - and has underlined both the deficiencies in this England team and the progress made by Bangladesh.
Set 286, they had made a positive start to their chase, losing Tamim Iqbal in the ninth over with 35 on the board as Ballance held a smart catch at short leg off Moeen Ali.
And at 81 for one with lunch approaching, they had enjoyed comfortably the better of the morning session, having already polished off England's two remaining second-innings wickets at a cost of just 12 runs.
But Rashid persuaded Imrul Kayes, on 43, into an ill-judged sweep, which ballooned off the glove and over the batsman's head to Root at slip.
Batty then struck in successive overs after lunch, removing Mominul Haque on leg-before review (the 22nd review of this extraordinary Test), then trapping Mahmudullah to make it 108 for four.
When Moeen Ali ripped one across the left-handed Shakib Al Hasan, providing Jonny Bairstow with a sharp take high to his left, Bangladesh had slipped to 140 for five, and an England victory looked only a matter of time.
But Rahim and Sabbir set about chipping away at the total, as the crowd grew along with the hosts' expectations.
Rahman twice deposited Moeen over the ropes, and England's mood wasn't helped when Jonny Bairstow put down a tough leg-side chance off Broad when Rahman had 34.
And Broad lost his temper with Kumar Dharmasena when the umpire signalled that England had taken too much time deciding whether to review a leg-before appeal against Rahman on 38 - though reviews showed it would have been not out anyway.
Earlier, England added an underwhelming 12 runs to their overnight 228 for 8, losing Broad to a careless run-out in the second over, and Batty for three, leg-before to Taijul Islam.
It left Bangladesh needing 286, comfortably more than they have ever made to win a Test. Indeed, they had only twice chased successfully in the fourth innings before.
Whether they will get any sleep on Sunday night considering the possibility is another matter.