Two late Grant McCann penalties gave Peterborough a Championship lifeline and dented Cardiff's promotion hopes.
Aron Gunnarsson had put Cardiff ahead, scuffing home from close range after Ben Turner flicked on a corner.
But when Don Cowie lost the ball near his own area the midfielder lunged in on Posh's Mark Little, with substitute McCann converting the spot-kick.
Then Dwight Gayle went tumbling under a Matt Connolly tackle and McCann stepped up to beat David Marshall again.
The result, which saw Peterborough complete the double over the Welsh side, continues a miserable run for Cardiff at London Road, a streak that has seen them go winless since October 1986.
Peterborough's reward for a battling display is to climb out of the Championship bottom three, above Wolverhampton Wanderers courtesy of goals scored.
Bluebirds blue in Peterborough
- Cardiff have only registered one league victory at Peterborough - a 2-1 win in October 1986 in the old Fourth Division
Leaders Cardiff, meanwhile, need 14 points from their remaining eight games to secure promotion to the Premier League and must regroup for Monday's clash at home to Blackburn Rovers.
The Bluebirds were forced on the defensive at the start as Posh went close through Gayle, whose shot from 18 yards was well held by Cardiff goalkeeper Marshall - making his 300th club career start.
Cardiff made their presence felt when Peter Whittingham tried his luck from the edge of the penalty area, but Robert Olejnik was well positioned in the Posh goal.
The Peterborough stopper was given little chance on 23 minutes when the visitors won a corner, Turner drifting to the front post to cause consternation in the Posh defence and Gunnarsson getting the final touch for his eighth goal of the campaign.
Posh pressed after the break and Kane Ferdinand's header brought a fine stop from Marshall, while Craig Alcock fired over the crossbar from 12 yards.
But Cardiff handed Posh the equaliser when Cowie lost possession as he retreated towards his own box.
The Scotland midfielder rushed back in an effort to make amends but compounded his mistake with an over-eager lunge on Little.
McCann - who had only entered the action two minutes earlier as a replacement for Ferdinand - showed few signs of nerves when he blasted home from the spot.
It was no more than Darren Ferguson's side deserved and it got even better for the hosts seven minutes later when Connolly fouled Gayle in the box and McCann again converted the penalty.
Rudy Gestede had two good, late chance to rescue a point for Cardiff but Peterborough held on to claim a crucial three points.
Peterborough manager Darren Ferguson:
"I wouldn't want anyone else other than Grant McCann standing over a penalty. He has a terrific record and put them both away superbly.
"We have beaten a team that is bound for the Premier League twice - and we have done it on merit on both occasions.
"Hopefully it turns out to be a big win for us. I'm not fussed about our league position because it is points that matter to me.
"March has always been a good month for us and that has certainly been the case again."
Cardiff City manager Malky Mackay:
"We've looked at the first penalty again and it's never been a penalty, Don [Cowie] actually kicks the ball and doesn't touch the guy at all.
"The boy has fallen over and the referee has fallen for the crowd shouting again, like they had been and we warned them at half-time. It's a real poor, poor decision.
"We're disappointed in our own defending roundabout both of the penalties because we caused our own problems to allow the referee the chance to give them.
"Because other than that they weren't near a goal the whole game; it was a scrappy game, the pitch was very hard and you could see that for both teams with wayward shots when the 'bobble' hits."
- 01 Olejnik
- 03 Alcock
- 05 Zakuani
- 19 Little
- 14 Rowe
- 17 Newell (Mendez-Laing - 55' )
- 18 Ferdinand (McCann - 70' )
- 20 Knight-Percival
- 26 Payne
- 08 Tomlin (Barnett - 90' )
- 34 Gayle
- 13 Day
- 04 Brisley
- 07 Swanson
- 11 McCann
- 38 Cuvelier
- 44 Mendez-Laing
- 09 Barnett
- 01 Marshall
- 03 Taylor
- 06 Turner Booked
- 12 Connolly
- 25 Barnett
- 07 Whittingham (Conway - 68' )
- 08 Cowie Booked
- 17 Gunnarsson
- 14 Smith
- 22 Helguson (Mason - 77' )
- 27 Campbell (Gestede - 58' )
- 32 Lewis
- 02 McNaughton
- 11 Conway
- 13 Kim Bo-Kyung
- 18 Mutch
- 15 Gestede
- 20 Mason
Live Text Commentary
Full Time The referee blows for the end of the match.90:00 +5:38
Don Cowie produces a cross, Rudy Gestede has a headed effort from close in and clears the bar.90:00 +4:13 Substitution
Substitution Lee Tomlin goes off and Tyrone Barnett comes on.90:00 +4:13
The referee blows for offside against Don Cowie. Indirect free kick taken by Robert Olejnik.90:00 +2:37
Shot by Rudy Gestede from 12 yards. Blocked by Robert Olejnik.90:00 +2:04
Aron Gunnarsson takes a shot. Blocked by Lee Tomlin.90:00 +1:00
Effort on goal by Lee Tomlin from just inside the penalty area goes over the target.89:50
Inswinging corner taken left-footed by Grant McCann from the right by-line, save made by David Marshall.89:04
Grant McCann decides to take the corner short.88:46
Effort from 12 yards by Lee Tomlin. Ben Turner gets a block in.88:14
Lee Tomlin has an effort at goal from outside the penalty box missing to the wide right of the target.87:07
Inswinging corner taken by Craig Conway from the left by-line, clearance by Gabriel Zakuani.86:29
Craig Conway fouled by Mark Little, the ref awards a free kick. The free kick is delivered right-footed by Craig Conway from left wing, Robert Olejnik makes a save.85:23
Jack Payne fouled by Rudy Gestede, the ref awards a free kick. Craig Alcock takes the indirect free kick.84:25
Short corner worked by Grant McCann.82:42
Craig Conway crosses the ball, blocked by Craig Alcock. Inswinging corner taken right-footed by Craig Conway from the left by-line to the near post, clearance by Grant McCann.80:36
Ben Turner takes a shot. Robert Olejnik makes a save.78:58 Goal scored
Goal! - Grant McCann - Peterboro 2 - 1 Cardiff Penalty taken left-footed by Grant McCann and scored. Peterborough 2-1 Cardiff.78:09
Penalty awarded for a foul by Matthew Connolly on Dwight Gayle.77:27
The referee gives a free kick against Joe Mason for handball. Free kick taken by Robert Olejnik.
Substitution Joe Mason replaces Heidar Helguson.75:55
Rudy Gestede takes a shot. Save by Robert Olejnik. The referee blows for offside against Tommy Rowe. Indirect free kick taken by David Marshall.75:13
The ball is sent over by Craig Conway, Nathaniel Knight-Percival manages to make a clearance.73:31
Shot by Craig Conway from deep inside the penalty area misses to the right of the target.72:44
Unfair challenge on Craig Conway by Grant McCann results in a free kick. Free kick taken by Craig Conway.71:48 Goal scored
Goal! - Grant McCann - Peterboro 1 - 1 Cardiff Power penalty scored by Grant McCann. Peterborough 1-1 Cardiff.70:54
Penalty awarded for a foul by Don Cowie on Mark Little.70:20
Jack Payne fouled by Aron Gunnarsson, the ref awards a free kick. Grant McCann takes the direct free kick.69:22 Substitution
Substitution Kane Ferdinand goes off and Grant McCann comes on.67:29 Substitution
Substitution Craig Conway replaces Peter Whittingham.67:20
Centre by Tommy Smith.65:21
Inswinging corner taken right-footed by Lee Tomlin from the left by-line to the near post, clearance made by Rudy Gestede.63:03
Centre by Tommy Smith, Rudy Gestede takes a shot. Save by Robert Olejnik.62:24
The assistant referee flags for offside against Dwight Gayle. David Marshall takes the free kick.61:04
Handball by Rudy Gestede. Nathaniel Knight-Percival takes the free kick.60:25
Centre by Tommy Rowe.58:27
Outswinging corner taken from the right by-line by Lee Tomlin, Craig Alcock produces a left-footed shot from inside the area that goes over the bar.57:19
Ben Turner makes a clearance.57:19 Substitution
Substitution Fraizer Campbell goes off and Rudy Gestede comes on.57:19
The ball is swung over by Nathaniel Mendez-Laing, clearance by Matthew Connolly. Corner taken right-footed by Lee Tomlin from the left by-line,56:05
Lee Tomlin is penalised for a handball. Andrew Taylor restarts play with the free kick.54:24 Substitution
Substitution Nathaniel Mendez-Laing replaces Joe Newell.53:13
Aron Gunnarsson produces a cross, Peter Whittingham takes a shot.50:06
Dwight Gayle concedes a free kick for a foul on Andrew Taylor. Free kick taken by Andrew Taylor.48:26
Corner taken short by Lee Tomlin. Centre by Joe Newell, Kane Ferdinand takes a shot. Save made by David Marshall.47:35
Aron Gunnarsson produces a right-footed shot from just outside the box that misses to the right of the net.45:52
Lee Tomlin has a drilled shot. Blocked by Don Cowie.45:01
The match restarts for the second half.45:00 +2:48 Half time
Half Time The referee blows for half time.45:00 +2:25
Headed effort from inside the area by Heidar Helguson misses to the left of the goal.45:00 +1:55
Dwight Gayle challenges Ben Turner unfairly and gives away a free kick. Andrew Taylor restarts play with the free kick.45:00 +1:33
Effort on goal by Joe Newell from just inside the penalty area goes over the target.45:00 +0:49
Corner taken by Lee Tomlin from the left by-line to the near post, Matthew Connolly manages to make a clearance.45:00 +0:36
The ball is swung over by Mark Little, Matthew Connolly manages to make a clearance.44:22
Tommy Smith gives away a free kick for an unfair challenge on Tommy Rowe. Lee Tomlin restarts play with the free kick.43:25
Free kick awarded for a foul by Ben Turner on Dwight Gayle. Direct free kick taken by Craig Alcock.42:14
The ball is delivered by Lee Tomlin, Headed effort on goal by Gabriel Zakuani from inside the penalty box misses to the right of the goal.42:14 Booking
Booking Don Cowie goes into the referee's book for unsporting behaviour.41:57
Free kick awarded for an unfair challenge on Joe Newell by Tommy Smith.41:36
Shot by Lee Tomlin. Blocked by Leon Barnett.40:54 Booking
Booking Booking for Ben Turner for unsporting behaviour.40:40
Fraizer Campbell takes a shot. Save by Robert Olejnik.39:14
Aron Gunnarsson is penalised for handball and concedes a free kick. Joe Newell delivers the ball from the free kick left-footed from right wing, save by David Marshall.37:58
Ben Turner concedes a free kick for a foul on Dwight Gayle. Craig Alcock restarts play with the free kick.37:11
Jack Payne produces a cross. The ball is swung over by Tommy Smith, Tommy Rowe makes a clearance.34:46
The referee blows for offside against Fraizer Campbell. Robert Olejnik takes the free kick.33:53
Shot by Aron Gunnarsson went over the net.33:40
The ball is delivered by Tommy Smith.32:06
Lee Tomlin has an effort at goal from 20 yards. David Marshall makes a save.29:19
The ball is crossed by Jack Payne, Tommy Rowe takes a shot. Save by David Marshall.26:13
Peter Whittingham takes a shot from just outside the penalty area which clears the crossbar.24:23
Aron Gunnarsson produces a cross, blocked by Tommy Rowe.23:57
Peter Whittingham crosses the ball, blocked by Lee Tomlin.23:00
Don Cowie gives away a free kick for an unfair challenge on Joe Newell. Jack Payne takes the direct free kick.22:02
Assist by Heidar Helguson.22:02 Goal scored
Goal! - Aron Gunnarsson - Peterboro 0 - 1 Cardiff Aron Gunnarsson finds the net with a goal from close range low into the middle of the goal. Peterborough 0-1 Cardiff.21:12
Don Cowie takes a inswinging corner.20:44
Effort on goal by Don Cowie from 12 yards. Gabriel Zakuani gets a block in.17:40
Shot from a long way out by Dwight Gayle goes wide of the left-hand post.17:10
Aron Gunnarsson sends in a cross. Peter Whittingham has an effort at goal from 18 yards. Save by Robert Olejnik.16:22
Aron Gunnarsson delivers the ball, clearance made by Tommy Rowe.14:51
Fraizer Campbell fouled by Jack Payne, the ref awards a free kick. Andrew Taylor takes the free kick.14:18
Leon Barnett challenges Dwight Gayle unfairly and gives away a free kick. Jack Payne takes the direct free kick.11:55
Fraizer Campbell gives away a free kick for an unfair challenge on Gabriel Zakuani. Robert Olejnik restarts play with the free kick.10:39
Craig Alcock concedes a free kick for a foul on Fraizer Campbell. Don Cowie delivers the ball from the free kick right-footed from left wing, save made by Robert Olejnik.7:58
The ball is delivered by Fraizer Campbell.7:14
Drilled left-footed shot by Dwight Gayle. Save made by David Marshall.6:19
Aron Gunnarsson concedes a free kick for a foul on Joe Newell. Free kick taken by Lee Tomlin.4:51
Foul by Lee Tomlin on Aron Gunnarsson, free kick awarded. David Marshall takes the free kick.2:07
Lee Tomlin takes a corner.0:00
The referee gets the match started.
Live data and text provided by our data suppliers