Scott Doe's header earned Dagenham a thrilling 3-2 victory over 10-man Rotherham which took John Still's side out of the bottom two.
The visitors dominated the first half with Jason Taylor, Lewis Grabban and Alex Revell all forcing saves from keeper Chris Lewington.
But Lewington was powerless to prevent the opening goal after 28 minutes as Millers skipper Danny Harrison volleyed home from 20 yards.
Daggers were much-improved after half-time and equalised when Michael Spillane's deep free-kick was headed in across goal by Jon Nurse.
The home side then took the lead just after the hour mark when Abu Ogogo exchanged passes with Brian Woodall and Ogogo's shot deflected off defender Mark Bradley and wrong-footed keeper Rhys Taylor.
Just a minute later, though, Rotherham were level. Scott Griffiths raced down the left flank and crossed for Revell to head past Lewington.
But Daggers' winner came with 12 minutes remaining as Doe headed in Cristian Montano's corner at the near post.
Rotherham defender Michael Raynes was sent off late on to complete a miserable second half for Rotherham as the Daggers picked up three vital points in their bid to beat the drop.