As the match entered seven minutes of additional time the Millers were winning 2-1 through goals from Ben Pringle and Jordan Bowery.
But, after Caolan Lavery had earlier levelled for Wednesday, Atdhe Nuhiu’s header in the third minute of injury time followed by Kieran Lee’s effort five minutes later won it for them.
It was an enthralling end to the match as four goals went in after the 86th minute, but with three of those being for Wednesday it meant a poor afternoon for the Millers.
At one point in the afternoon they were heading nine points clear of the dropzone but, following Wigan’s late leveller against Bolton and Wednesday’s late show, Steve Evans’ men are now only five points ahead.
A 15-minute delay to kick-off only heightened the derby atmosphere and in an open start both goalkeepers were forced into saves in the opening 10 minutes.
First Wednesday’s Keiren Westwood produced a fine block to deny Matt Derbsyhire in the fifth minute before Millers debutant, Damian Martinez, on loan from Arsenal, provided an early showcase of his talents by palming away a good Lewis McGugan effort.
Rotherham needed an impressive block from defender Kirk Broadfoot to stop Lee giving the visitors the lead as the game continued its end-to-end nature, before Westwood again provided more heroics with a reflex save from Derbyshire’s glancing header from Pringle’s corner.
Evans’ men were more in need of the points than the mid-table Owls and they made a strong start to the second period, with a lengthy spell of pressure was rewarded with Pringle’s 57th minute strike.
A long ball into the area was cleared to the edge of the area and the Millers winger struck a low effort which was deflected off Tom Lees, wrong-footing the helpless Westwood.
The Millers were rampant and they came close to doubling their lead in the 64th minute but Jack Hunt’s fierce effort after his surging run went just wide.
Wednesday were offering very little in way of a response and Derbyshire had a third chance of the match to get on the scoresheet but he sent a volley flying just wide.
As the match entered its final 10 minutes the Owls finally stirred as Rotherham invited them on and they levelled with four minutes of normal time remaining.
Some fine play from McGugan on the left wing allowed him to get to the byline and he crossed for Lavery to head home.
Almost straight from kick-off the Millers thought they had won it again as Bowery picked the ball up on the left and shot home at the near post.
But Wednesday performed a late, late show as Nuhiu’s header from a free-kick and Lee’s breakway goal meant they took the bragging rights in the South Yorkshire derby.
Sky Tickets are giving you the chance to experience live Championship football. Buy tickets & get a free NOW TV Sky Sports Pass PLUS you could win Soccer AM tickets.