Michael Keane's second-half header looked to have sentenced Cardiff to their second defeat in three home games.
But two minutes into time added-on substitute Gestede converted Andrew Taylor's cross to increase their lead over Hull at the top of the table to four points.
Sam Byram salvaged a 1-1 draw for Leeds but his side's hopes of closing in on a play-off place ended in frustration as Peterborough made it three games unbeaten on their travels.
Leeds teenager Byram turned home his fourth goal of the season early in the second half to cancel out Dwight Gayle's stunning opener for an impressive Peterborough side aiming to climb out of the bottom three.
But although Leeds pushed the visitors back for long periods after the break they were thwarted at every turn by a resolute defence in their bid to close to within three points of the top six.
And Barnsley breathed fresh life into their survival fight with a 2-1 victory which did further damage to Brighton's stuttering play-off ambitions.
The Reds, who were beaten 5-0 by Manchester City in the FA Cup on Saturday, went into the match without a win in three league games and sitting bottom of the table.
But Jason Scotland gave them an early lead when he struck home following some powerful forward play and they then showed their mettle as they regained the lead through Chris Dagnall's penalty just five minutes after Leonardo Ulloa had headed Brighton level on the hour mark.
Ulloa's night ended in misery, though, as he saw a late penalty saved by heroic Barnsley goalkeeper Luke Steele as the hosts held on for a valuable win which lifts them out of the bottom three.
- Sports & Recreation