Carlo Ancelotti's side suffered a 3-2 loss to Rayo Vallecano in the league on Monday, which followed a 1-1 draw with Girona at Bernabeu at the end of October.
The gap to La Liga leaders Barcelona was five points ahead of kickoff at Bernabeu, but the narrow victory means that the reigning champions are now two points behind the Catalan side heading into the break for the World Cup.
Rodrygo had a sight of the Cadiz goal in the fifth minute of the contest, but the Brazilian's effort never threatened to cause the away side's goalkeeper Jeremias Ledesma any major issues.
Luka Modric then whistled one over the Cadiz crossbar in the ninth minute, before Alfonso Espino just missed the target for the visitors with a powerful drive two minutes later.
Real Madrid managed to make the breakthrough in the 40th minute of the contest, though, with Militao heading a Kroos cross into the back of the net from close range after Cadiz had failed to fully clear a corner.
The Yellow Submarine had an opportunity to level the scores early in the second period when Anthony Lozano's flick found Ruben Sobrino inside the box, but Los Blancos goalkeeper Thibaut Courtois was on hand to make a smart save.
Real Madrid had a chance of their own moments later when Vinicius Junior found Federico Valverde in the middle of the box following a quick break, but Isaac Carcelen was on hand to make a brilliant block.
The home side doubled their advantage in the 70th minute, though, when Kroos, who was the provider for the opening goal of the contest, found the bottom corner with a brilliant volley.
Vinicius forced Ledesma into a smart save in the 77th minute before Modric missed the post shortly after, as Real Madrid threatened a third, but it was Cadiz that struck in the 82nd minute, with Lucas Perez converting from close range after Courtois had kept out efforts from Theo Bongonda and then Alvaro Negredo.
Cadiz had a chance to snatch a point late on when Espino found Negredo, but the experienced forward's header was kept out by Courtois, and Real Madrid closed the match out to collect an important three points, but they had to survive another scare when Espino looped one over the crossbar in the 93rd minute.