Two goals in the last three minutes kept Arsenal top of the Premier League and condemned Cardiff to defeat in front of Ole Gunnar Solskjaer, who is tipped to take over as their new boss.
Nicklas Bendtner fired in the opener from close range before immediately going off with an ankle injury and in the 90th minute, Theo Walcott – who had earlier hit the post – converted Jack Wilshere’s sublime pass.
Cardiff are set to name Solskjaer as successor to Malky Mackay.
And the former Manchester United striker was sitting alongside Bluebirds’ owner Vincent Tan in the Emirates Stadium directors’ box after holding talks to take over as manager.
The Norwegian would have been encouraged with what he saw as the well-organised visitors held Arsenal until the dying minutes when goals from substitute Bendtner and Walcott left Cardiff only two points above the drop zone.
For a long time it looked as though Arsene Wenger’s men, who started the day top before briefly being displaced when Manchester City won the early kick-off game, would be left frustrated as they enjoyed plenty of the ball without being able to break Cardiff down.
The hosts were restricted to half chances for the majority of the first half, with Walcott side-footing the best chance over the bar.
A lot of the main striker responsibilities at Arsenal have fallen to Olivier Giroud this season but, with the Frenchman missing with an ankle injury, Lukas Podolski made his first start since August.
Arsenal have not been prolific at home so far this season, going into the match with only 16 league goals from nine matches.
And the Gunners’ lack of striking options will inevitably lead to more questions being directed at Wenger about potential targets this transfer window, with the first half display doing little to convince they have a suitable replacement for Giroud.
Cardiff, going into the game with only one league win in nine matches, defended deep but looked dangerous on the break as Fraizer Campbell worked tirelessly in attack.
The few Arsenal chances that did arrive mostly fell to Walcott, who shot into the side-netting while stretching from a Wilshere cross early on before just failing to get on the end of a Mikel Arteta through ball.
Wilshere had a penalty appeal turned down late in the half after going down under the challenge of Gary Medel, who looked to have made contact with the Arsenal man and not the ball.
An injury-hit Gunners side, who were also missing Aaron Ramsey, Mesut Ozil, Kieran Gibbs and Tomas Rosicky, continued to struggle to create chances in the opening stages of the second half, although they were enjoying the majority of the possession.
With Bendtner on in place of Podolski the Gunners finally upped the tempo and almost took the lead when Wilshere cut inside before striking a shot against the post.
Per Mertesacker then headed wide twice when unmarked before the deadlock was broken as Bendtner was quickest to react when David Marshall saved Bacary Sagna’s header, the Dane firing home with just two minutes remaining before immediately going off injured.
The victory was sealed as Walcott calmly chipped over Marshall after latching on to Wilshere’s flicked through ball.