Stephen Foster's last-gasp equaliser gave Barnsley a crucial point in their fight against relegation and denied Championship leaders Cardiff.
Victory would have left the Bluebirds potentially a win away from promotion and Ben Turner's goal looked to have put them closer to the Premier League.
But, after Heidar Hegluson missed a glorious chance to double the lead, Foster equalised in the 97th minute.
The point takes Barnsley two points above the relegation zone.
But there were few signs of the late drama that stunned the Cardiff City Stadium crowd into silence as the game went over the allotted five minutes for stoppages.
Cardiff knew that victory over the Tykes would set up a potential promotion party at home to Nottingham Forest on Saturday.
And they looked set to collect another three points as they defended Turner's second-half opener without much alarm.
Barnsley showed little appetite to leave the Welsh capital with anything more than a draw, allowing Cardiff to enjoy almost total dominance, particularly in a one-sided first half.
The Bluebirds have been top of the Championship table since beating Barnsley on 24 November, and another victory would have taken the Bluebirds eight points clear at the top and 11 points clear of third-placed Watford.
A draw means they must settle for a six-point lead over second-placed Hull, and prolongs their bid to secure promotion.
A few nerves have been obvious in recent home Cardiff performances, resulting in a run of just one win in their last four games.
But there was a zest and determination in their play against their limited opponents, with Craig Bellamy's infectious energy setting the tone from the first whistle.
The visitors failed to register a single shot on target in the first half and were pushed deeper into their own half as the game progressed.
Bellamy came closest to finding the deserved breakthrough in the first half when his effort was turned onto the bar by Barnsley goalkeeper Luke Steele.
Jordan Mutch was next to threaten with a 25-yard drive that drew a superb fingertips save from Steele.
But the home side were fortunate to escape moments after the restart when Bobby Hassell headed wide from a yard out as he stumbled backwards at the far post.
Normal service soon resumed, though, as Cardiff increased the pace.
A flowing Cardiff move resulted in a driven shot from Kim Bo-Kyung deflecting wide for a corner before another corner eventually yielded the breakthrough.
Kim delivered with pace, and Turner stuck out a leg at the far post to score his first goal of the season.
Mutch then saw a shot deflect over and Helguson headed wide. But substitute Helguson was guilty of a glaring miss when a poor finish allowed Steele to save.
That seemed to galvanise Barnsley, and they showed the determination that has brought 11 wins from their last 18 matches with a late push forward.
Cardiff looked unsettled for the first time, and Foster's deflected shot in the 95th minute left Marshall with little hope as the visitors snatched an unlikely draw.
Cardiff manager Malky Mackay:
"The extra time was for [Cardiff defender] Kevin McNaughton going down [for treatment]. I wanted the referee to clear that up, which he did.
"When they scored there were four seconds to go, he was going to blow the whistle four seconds later and I am absolutely fine with that.
"I was delighted with how we played, we were playing a team fighting for their lives. David [Flitcroft, Barnsley manager] has them working very hard and they have outworked teams to death.
"Tonight that did not happen. We dominated and we had chances. We could have been more clinical and finished the game off. At 1-0 anything can happen, including a freak goal."
Barnsley manager David Flitcroft:
"That is more than a point for us. To fit this game into our programme after the game against Crystal Palace and after Easter week, it was asking a lot of this group.
"But you cannot ask for more than going 97 minutes against the champions-elect.
"This gives us real momentum and confidence ahead of the Charlton game.
"At five minutes McNaughton went down, I don't know why he went down but that is where you get your extra minute from."