Andy Keogh grabbed a last-gasp winner to break the hearts of Kenny Jackett's battling bravehearts at the Cardiff City Stadium.
Keogh's 89th-minute clincher was a bitter pill for The Lions to swallow, having put on a valiant display despite playing with 10 men following the 42nd-minute dismissal of Liam Trotter.
It had all started so brightly for Millwall when Scott Barron scored his first goal of the season to put the visitors ahead, only for Jay Bothroyd to level on 23 minutes.
Former Bluebirds keeper David Forde then produced a brilliant penalty save on the stroke of half-time to deny Peter Whittingham, but Keogh grabbed a sickening winner right at the death.
Following successive home defeats at the hands of Watford and Ipswich Town, The Lions had wanted to prevent any rot setting in, and although ultimately this result was harsh on Millwall, boss Jackett could take a string of positives from this display.
Jackett has remained resolute in his belief that The Championship is very much a learning curve for his Lions as they adapt to a higher level of football, in what is only the eighth league fixture of the campaign.
Not only are his team still finding their feet a division up, but on Saturday they were adapting to a new formation - and then the rarity of operating for around 50 minutes with 10 men following Trotter's red card.
The influential figure of Trotter started in an advanced role in a 4-5-1 system, with Tony Craig making his first league start of the campaign at left-back and Barron switching to a wide midfield role.
Millwall started with a crispness about their play that had been missing in the previous two games, and took a deserved lead on 10 minutes.
David Forde, making his 100th league start for The Lions, cleared forward straight down the middle. The ball was won by Trotter who showed great strength and skill to keep possession before spraying wide to Kevin Lisbie on the right. He in turn moved forward and drilled a low ball across the face of goal that Barron swept home with aplomb.
The Lions, backed by just under 1,300 supporters, looked comfortable in possession, bright going forward and pretty much in control of proceedings.
However the home side hauled themselves level from what was effectively a nothing situation midway through the opening half.
A long throw from the left should have been cleared by the visiting defence and former Arsenal trainee Bothroyd was perfectly placed to capitalise on the hesitancy and fire an angled drive beyond Forde's reach.
That goal sparked Cardiff into life and the game really opened up with the two teams trading scoring chances.
Bothroyd shot high, wide and then sent a header straight into Forde's hands from close range while Jackett's men worked some good positions of their own.
Millwall were a whisker away from regaining the lead twice in as many minutes around the half-hour mark.
Steve Morison's pace and power enabled him to make space before delivering an inviting ball that was inches away from the boot of Barron, whilst another sweeping move down the right saw the busy Kevin Lisbie's cross blocked with Trotter set to swoop.
But it was Trotter, an immense figure in his supporting role to Morison, who was shown a straight red card for a challenge on Darcy Blake that looked more clumsy than intentional.
However within seconds of finding themselves at a numerical disadvantage, it was Millwall who could have restored their advantage when a brilliant run by Lisbie set up Morison, but the striker's chip floated just over the bar with keeper Tom Heaton in no man's land.
At the other end the travelling fans couldn't believe their eyes, nor Cardiff their luck, when Whittingham went down under the feintest of challenges from Darren Ward and referee Lee Mason pointed to the spot.
Justice prevailed thankfully when Forde flung himself low to his right to somehow push Whittingham's spot-kick around the post for a corner.
Millwall came out at the start of the second-half in determined mood and showed their intent when first Morison's powerful cross swerved away from under the bar and then Tamika Mkandawire headed a yard over from Barron's inswinging free-kick.
Forde came to the rescue when he got a touch to clear Bothroyd's drilled cross after the flag had stayed down with the Cardiff man looking suspiciously offside.
The Lions were forced to reshuffle their pack on 68 minutes when Lisbie hobbled off, with Danny Schofield stepping into the fray.
It was Schofield who nearly scored with his first touch, picking up Morison's deft flick only for Mark Hudson to get a touch on the ball as the sub shaped to shoot from a central position.
Schofield was involved in the thick of the action again with a left-foot drive that flashed narrowly wide of the left hand post as Millwall again produced some delightful football.
Cardiff did finally start to drive further forward as the game wore on, getting the ball into wider positions quicker following the introduction of Jason Koumas and Gavin Rae.
And it was from Koumas' goalbound effort that Craig made a magnificent goalline clearance to prevent the hosts taking the lead, with TC celebrating his timely intervention as if it were a match-saver, which it really should have been.
Morison was then penalised for what was, once again, a soft free-kick just inside his own half in the 89th-minute, for which he received a yellow card for 'persistent fouling'.
The cruel irony was that not only were The Lions equally sinned against than sinning, but that when the resulting free-kick was cleared, Bothroyd returned the ball into the danger zone and there was Keogh to send his header past Forde.
It was heartbreaking stuff for Millwall, who have no time to feel sorry for themselves with a trip to table-topping QPR on the horizon this Tuesday.
These Lions are never more dangerous than when they are wounded. You have been warned!
Cardiff City: Heaton, McNaughton, Naylor, Hudson, Gyepes, Whittingham, Bothroyd, McPhail (Koumas, 64mins), Burke (Rae, 81mins), Keogh, Blake. Subs not used: Marsh, Quinn, Taiwo, Matthews, Wildig.
Booking: Keogh (89mins)
Scorers: Bothroyd ( 24mins), Keogh (89mins)
Millwall: Forde, Dunne, Craig, Abdou, Robinson, Ward, Barron, Trotter, Lisbie (Schofield 68mins), Morison, Mkandawrire. Subs not used: Mildenhall, Harris, Hackett, Henry, Smith, T.Robinson.
Bookings: Morison (88mins), Dunne (90+2mins)
Sent off: Trotter (39mins)
Scorer: Barron (10mins)
Ref: Lee Mason