Two extra-time goals from Jon Nurse booked Dagenham a place in the FA Cup second round at the expense of Bath.
The League Two strugglers took a first-half lead as Richard Rose's right-wing cross was met by Brian Woodall's head.
Bath, who are bottom of the Blue Square Bet Premier, levelled through Adam Connolly from 25 yards.
Nurse put the visitors back in front as he latched onto a long clearance and then secured a second-round tie with Walsall by converting a breakaway.
Bath more than matched their Football League opponents throughout the tie and Alex Russell hit the post from a free-kick in the first half, while substitute Scott Murray went close in extra-time.
VIEWS FROM THE DRESSING ROOM
Bath City midfielder Adam Connolly tells BBC Radio Bristol:
"Even when we were 1-0 down we knew we were still in the game.
"We feel like we've had a couple of decisions in both games that have gone against us and it's cost us.
"Now we are out and it's very disappointing."