Callum Camp's early goal for Rochdale was cancelled out during a brilliant six minute flurry that saw Aiden O'Brien extend his goal-scoring streak and Lee Gregory convert a penalty, but the main talking point from Saturday's match was Millwall midfielder Ben Thompson's controversial sending off.
Making his 50th appearance for the Lions, Thompson saw red when the referee ruled he had intentionally taken out Matty Lund while contesting a high ball in the middle of the park. The decision to issue a second yellow card turned the match on its head, with two late goals earning Rochdale their second League One win of the season.
Striker Lee Gregory returned to the starting line-up for the first time for the first time in a month, alongside Sid Nelson and Ben Thompson.
The Lions struggled to gel in the opening exchanges and gifted Rochdale a goal in the eighth minute when Callum Camps drove his shot past Jordan Archer's reach after getting on the end of an unchallenged Joe Thompson cross.
Then came the fightback, courtesy of a predator's goal from Aiden O'Brien two minutes later. Lee Gregory escaped through the middle and squared for O'Brien to bury the ball nto the bottom corner.
Gregory was on the spot again seven minutes later to help double Millwall's lead. The striker streaked passed the flat-footed Rochdale defence and squeezed a pass through to O'Brien, who was shoved roughly to the ground inside the area for a penalty.
The crowd roared as Gregory sent the keeper wrong way and drove the spot-kick into the net to send the hosts into the break with a deserved 2-1 lead.
Half-time brought a chance to regroup and Rochdale levelled the scores in the second half through a well taken free-kick. Joe Bunney whipped in a dangerous ball from 30 yards out and Calvin Andrew rose above the rest to plant a firm header into the back of the net on 67 minutes.
Soon after losing the lead, the match became an uphill battle for Millwall when they were reduced to 10 men, 20 minutes from time.
It set-up a frantic end to the match. Both sides seemed destined to share the spoils, but Rochdale snatched the win at the death when the ball dropped to substitute Steven Davies in the area and Sid Nelson caught his legs while trying to clear his lines. The resulting penalty was converted by Ian Henderson to bring about an end to a frustrating contest.
Millwall: Archer, Craig, Williams, Thompson, Gregory (Onyedinma, 87 mins), Romeo, Nelson, Webster, Ferguson (Abdou, 75 mins), Morison, O'Brien (Worrall, 26 mins)
Bookings: Thompson (72 mins), Abdou (93 mins), Williams (87 mins), Webster (69 mins)
Subs not used: King, Wylde, Butcher, Chesmain
Rochdale: Lillis, Canavan, McGahey (Rafferty, 45 mins), Lund, Andrew, Camps, McDermott (Davis, 52 mins), Thompson (Odelusi, 61 mins), Keane, Bunney, Henderson
Bookings: Andrew (84 mins) Bunny (45 mins)
Subs not used: Logan, Rathbone, Noble-Lazarus, Allen