Victor Camarasa had given the home side the lead in the first minute of the second half but a controversial offside goal from Azpilicueta and Loftus-Cheek’s header in the 90th minute rescued a crucial three points for the Blues.
But the Blues struggled to come out of the blocks as Cardiff pressed them high in their own half.
It didn’t take long for the first moment of controversy when Antonio Rudiger appeared to be pulled down by Aron Gunnarsson in the penalty area. But with referee Craig Pawson unsighted, play continued.
Chelsea began to find their feet and nearly took the lead when Pedro’s left-footed effort from 20 yards clearing the crossbar by a matter of inches.
But Cardiff were showing their own intent to attack and Jacob Murphy was unlucky to see his curling effort sail inches wide of the far post, having beaten Marcos Alonso with some fine skill.
The home side should have been awarded a penalty themselves when Sean Morrison was hauled down by Rudiger, but again, Mr Pawson was unmoved.
A sheer lack of chances towards the end of the half capped a poor half of football, but things soon improved after the interval – at least it did for Cardiff.
Just a minute after the restart, Lee Peltier’s cross found Victor Camarasa free in the box and the Spaniard hit a sweet volley into the top corner to hand the Bluebirds a huge goal.
Chants of “we want Sarri out” and “you don’t know what you’re doing” soon emerged from the away support to highlight their discontent.
Sarri responded to going behind by sending on Eden Hazard and Ruben Loftus-Cheek just 10 minutes into the second half and the pair almost had an immediate impact, combining in the Cardiff box before the hosts scrambled it away.
But the leveller came from an unlikely source when Willian’s corner was diverted by Giroud into Azpilicueta’s path and he headed home, and the goal was given despite the clear offside, leaving Neil Warnock furious.
There was still time for more drama when Willian’s cross was headed home by Loftus-Cheek in the final minute to steal all three points.