Kenneth Zohore scored a 93rd-minute winner to give Cardiff a 2-1 victory at Southampton which moved them out of the Premier League's bottom three, on a day when both clubs paid tribute to Emiliano Sala.
Cardiff warmed up in shirts featuring an image of their striker, who this week was confirmed to have died in a plane crash, and there was a minute's silence before kick-off.
When the action got underway at St Mary's, the first half was a quiet one, but Sol Bamba (69) slotted home after the break to put Cardiff ahead.
It looked like Southampton had snatched a point in the first minute of added time when Jack Stephens netted at the back post, but it was the visitors who had the final say as Zohore managed to sneak the ball into the net and seal all three points for the Bluebirds.
Cardiff have now won consecutive top-flight matches for the first time since April 1962 and go above Southampton into 16th place, while Saints drop into the relegation zone after Burnley's 3-1 win at Brighton, now in 18th on goal difference.
Southampton: McCarthy (6), Bednarek (6), Stephens (6), Vestergaard (6), Valery (6), Hojbjerg (6), Romeu (4), Ward-Prowse (5), Bertrand (6), Long (5), Redmond (6).
Subs used: Austin (4), Elyounoussi (4), Gallagher (n/a).
Cardiff: Etheridge (6), Peltier (7), Manga (7), Bamba (7), Bennett (7), Arter (6), Ralls (6), Paterson (7), Gunnarsson (6), Reid (4), Niasse (5).
Subs used: Bacuna (5), Zohore (6), Camarasa (5).
Man of the match: Sol Bamba.
Southampton shaded the few chances in the first half, and went close in the 12th minute. Ryan Bertrand burst down the left-hand side before whipping a cross into the area. Hojbjerg attempted a shot, but could not connect, before the ball was sent just wide by the leg of Lee Peltier.
The only shot on target of the opening period came in the 39th minute as Joe Ralls' headed clearance fell to the feet of Hojbjerg, who tried his luck from 20 yards, but it went straight into the hands of Neil Etheridge at the near post.
Southampton made four changes with Ryan Bertrand, Pierre-Emile Hojbjerg, Yan Valery and Shane Long coming into the side. Cardiff made just one as Harry Arter came back in for Josh Murphy.
Cardiff scored from their first corner of the game in the 69th minute. Ralls delivered the set-piece, which Callum Paterson nodded down towards the back post. Bamba had got away from his marker, Oriol Romeu, to slot home before jumping over the hoardings and celebrating with the away fans.
Five minutes later and Cardiff could have had a second. A clearance from Romeu landed to January signing Leandro Bacuna, who powered the ball towards goal and forced a save from Alex McCarthy. Southampton also saw three efforts blocked in quick succession in the 77th minute, with a Yan Valery shot saved by the foot of Etheridge before Charlie Austin was twice denied by Peltier.
As five minutes of added time were shown, Southampton found the back of the net. James Ward-Prowse delivered a corner which whistled across the face of goal and found the incoming Stephens at the back post, and he slotted home past Etheridge.
But the result was not yet decided as, two minutes later, Cardiff scored their all-important winner. Harry Arter's lashed effort found the feet of Victor Camarasa, who did well to hold the ball up before laying it off to Zohore. He then fired through the packed box and saw it squeeze into the bottom corner as Cardiff snatched all three points.
- Southampton lost for the first time in six Premier League games (W2 D3).
- Southampton have kept just one clean sheet in their last 16 Premier League games (0-0 v Chelsea in January).
- Cardiff have netted three 90+ minute winners in the Premier League this season, a joint-high figure along with Wolves.
- Cardiff's Kenneth Zohore has registered two goal involvements in his last three Premier League appearances (1 goal, 1 assist), after managing just one in his previous 15 league games.
Ralph Hasenhuttl: "It's not about mentality, we tried everything and in the last few weeks, we went five games unbeaten so the last situation was stupid because we were not doing what we planned to do.
"I think the opponent shot three times on our goal and twice it was a goal. We had more chances and more ball possession but we can't talk about tactics today, it's not interesting for me because the main part is that we can't have a clean sheet and if you don't have that, then you have no chance to stay in the league, that is for sure."
Neil Warnock: "You don't concede in the 93rd and score in the 94th very often, it's all the highs and lows. Their [Southampton's] staff were celebrating when they scored, and quite rightly so. I can't describe it really, it all went quiet for me, I was oblivious to all the noise when the winner went in.
"It was one of those times to have a think and I think we did Emiliano proud today for remembering him and that's a pleasing thing for me as well."
Man of the match - Sol Bamba
Bamba showed pure passion in what was another emotional game for Cardiff. He showed great awareness to be in the right area for his goal and he went straight to the fans to celebrate.
He also did his defensive work well, keeping Southampton at bay for much of the game and especially when they were peppering the Cardiff box in the first half. Neil Warnock said after the game: "Sol has been absolute fantastic since Sean Morrison, our captain, got injured, he's lead the team and everyone has responded to him."
Southampton now have a break of over two weeks, with their next game coming in the Premier League against Arsenal on Sunday February 24. Cardiff also have an extended period of rest before hosting Watford in the league on Friday February 22.