Rotherham moved back into the League Two play-off places as they eased to victory at Torquay.
Gulls goalkeeper Michael Poke made a mistake as Lee Frecklington's long-range effort went in.
Alex Revell doubled the advantage as he outpaced Aaron Downes to a through ball and slotted it past Poke.
Billy Bodin converted a last-minute penalty for Torquay before Kayode Odejayi capitalised on slack defending for Rotherham's stoppage-time winner.
The match was the fourth in a row that Torquay have played without manager Martin Ling.
The 46-year-old has been since last month.
VIEW FROM THE DRESSING ROOM
Rotherham United manager Steve Evans told BBC Radio Sheffield:
"Well, it was a hard fought win. The pitch was never conducive to good football and as you can see it's not the best in the league.
"You have to come here and work hard.
"We didn't play well in the first half and the penalty, I think we were unfortunate to have that given against us. It was a good win for us."