Ipswich Town missed the chance to reclaim the second automatic promotion spot in the Championship as Cardiff City scored two injury-time goals to snatch a stunning victory.
Cardiff started strongly and should have taken an early lead but Perry Ng's scuffed close-range effort was cleared off the line by Kieffer Moore.
Subdued during the first half, Ipswich looked more like their usual fluent, attacking selves after the interval with substitute Omari Hutchinson forcing Ethan Horvath into a good save.
The visitors probed patiently as the match wore on, gradually taking control before former Cardiff striker Moore fired into the far corner with a powerful left-footed finish.
Just as Ipswich looked to be heading level on points with Championship leaders Leicester City, Ryan Wintle scored with a deflected shot from close range five minutes into added time.
Then five minutes later, substitute Callum O'Dowda volleyed in from Famara Diedhiou's flick-on at a corner to spark ecstatic celebrations at Cardiff City Stadium.
The end of Ipswich's six-match winning run means they remain third in the table, trailing second-place Leeds United - who won at Sheffield Wednesday on Friday night - by one point.
Cardiff remain 10th but move within four points of the play-off spots after producing one of their best performances of the season.
Their goals may have come in the dying moments but, based on the balance of play over the course of the contest, Erol Bulut's side were worthy of victory.
While Ipswich were looking to extend a six-match winning streak, Cardiff were enjoying a revival of their own having won their previous three games.
The Bluebirds looked rejuvenated as they made a flying start, playing at a high tempo and pinning their opponents back with a flurry of early chances.
After David Turnbull's swerving shot was palmed away by Vaclav Hladky, the Ipswich goalkeeper was called into action from the subsequent corner as he kept out Josh Bowler's volley, before Ng's mishit effort on the rebound was cleared off the line by Moore.
Moore, the former Cardiff striker who had been a transfer target for the Welsh club during the January window, was booed on his return to the Welsh capital, and he came close to silencing those jeers when he backheeled wide from Wes Burns' fine low cross.
Despite that fleeting opportunity, Ipswich took a little longer than usual to settle into the game and were indebted to a handful of Hladky saves for keeping them level.
Cardiff's first-half performance was as good as any they had produced all season but could not convert their pressure into goals.
Ipswich slowly started to impose themselves on the game after the interval, dominating possession and territory.
Moore looked to have earned them victory - and moved them back into the automatic promotion places - when he collected a pass from substitute Marcus Harness, took a touch and drilled his finish into the bottom far corner.
But Cardiff responded superbly and finished the game as they started it.
Wintle got the equaliser their efforts deserved when he fired in - via a deflection - from close range and, rather than simply hold on for a draw, the home side pushed on for the win.
The decisive strike came in the 10th minute of added time and, as has so often been the case for Cardiff this season, it arrived via a set-piece.
Diedhiou acrobatically flicked on from a corner towards O'Dowda and the substitute volleyed in to prompt wild scenes of celebrations among the home fans, while delivering a blow to Ipswich's promotion hopes.
Cardiff City: Hovarth, Ng, Goutas, Phillips, Wilson-Esbrand, Siopis, Wintle ©, (Ralls 90+6) Turnbull (Colwill 75’), Grant, Bowler (Diedhiou 85’), Méïté (O’Dowda 75’). Subs not used: Turner, Romeo, Collins, Tanner, Ashford.
Ipswich Town: Hladky, Clarke, Woolfenden, Burgess, Davis, Morsy ©, Luongo (Taylor 76’), Burns (Harness 76’), Chaplin (Hutchinson 65’), Sarmiento (Broadhead 65’), Moore (Al-Hamadi 89’) Subs not used: Walton, Tuanzebe, Travis, Jackson.