Tudgay struck in injury time after Chris Wood appeared to have salvaged a point for the Lions, who had lost just once in their previous 16 matches.
Barnsley led through a first-half goal from Stephen Dawson, shortly after Millwall's Darius Henderson had missed a penalty.
To make matters worse, the hosts had defender Adam Smith sent off for a rash challenge early in the second half.
Wood tucked in his third goal in two matches, and his 11th of the season, 10 minutes from time but Tudgay had the last word as Millwall slipped out of the play-off places.
First Lions goalkeeper David Forde did well to tip Tudgay's shot round the post, then a mix-up in the Millwall defence saw the ball fall to Tudgay again, but this time the striker blazed his shot over the crossbar.
The hosts should have taken the lead in the 25th minute after Henderson was fouled in the area by Scott Wiseman. But Henderson, back in the Millwall side after a spell out with a hamstring injury, blazed the spot-kick over the crossbar.
And the Lions were made to pay five minutes later when Barnsley broke at the other end through Tudgay. The ball eventually fell to Jim O'Brien, whose shot was well saved by Forde, but Dawson was on hand to tuck away the rebound for his third goal of the season to give the visitors the lead.
Tykes goalkeeper Luke Steele was then called into action to make saves from Henderson and Shane Lowry.
Millwall's task got more difficult 10 minutes after the interval when Smith was sent off after he lunged in on David Perkins. It looked like a 50-50 challenge but referee Trevor Kettle deemed it to be two-footed and produced a straight red card.
Barnsley sensed the chance of a rare win and Perkins drove the ball goalwards but his effort was kept out by Forde.
Barnsley were caught out 10 minutes from time when Wood latched onto Dany N'Guessan's ball over the top and coolly finished past Steele. But all Millwall's hard work was undone when Tudgay rifled the winner past Forde in the 93rd minute.