Substitute Aiden O'Brien had looked to have secured the home side a point when he bundled in to cancel out Conor Chaplin's first-half strike with five minutes to go.
But in the final moments of stoppage time, Schmidt, who had come on just six minutes earlier, rose highest to head into the corner and ensure Gerhard Struber's men recorded back-to-back wins for the first time this season.
Millwall had dominated the early stages but couldn't create clear-cut chances against a resolute Tykes defence.
All of the home side's best chances in the first half fell to centre-half Jake Cooper – a constant threat from set-pieces.
First, the big defender was inches away from meeting a cross with the goal gaping and then twice he got on the end of Jed Wallace deliveries, only to head wide.
From open play, Gary Rowett's side were altogether less impressive, a Tom Bradshaw header from 12 yards their only effort before the break that didn't originate from a set-piece.
Barnsley began to grow in confidence as the first half went on but it was still firmly against the run of play when they took the lead – in fact it was from their very first shot of any description.
But it was well worth the wait as Chaplin beautifully diverting Jacob Brown's cross over Bartosz Bialkowski and into the far corner.
It was a seventh goal in seven games for the in-form striker, who had managed to find the net only once this season before Struber took over.
And it could have been 2-0 before the break, Bialkowski forced into a fine save to deny Chaplin after a speedy counter-attack.
Barnsley started the second half as they had ended the first, with Brown and Alex Mowatt bringing saves from Bialkowski as the visitors began to match their lead on the scoreboard with control on the pitch.
Millwall finally began to provide a response around the hour mark, though. Cooper again went close from a corner, diverting Shane Ferguson's delivery into the ground and then up and over the bar, before Bradshaw turned Wallace's driven cross just over the bar.
Still they failed to test Samuel Radlinger with a single shot on target until the final five minutes, when substitutes Matt Smith and O'Brien combined to level the scores – the latter nodding in the former's initial header from close range.
That ought to have been enough to earn the hosts a point they had scarcely deserved but they failed to clear a late corner and Schmidt found the space to head home a dramatic winner.