Militao scored the winner in the third minute, ghosting between several defenders to head home from close-range from a corner by Luka Modric.
Yet despite their early breakthrough and a dominant performance, Madrid were unable to break down Getafe’s defensive wall and extend their lead.
Playing at Getafe has often caused trouble for Madrid, who were winless in their two previous visits to the Coliseum Alfonso Perez, having failed to score in both matches.
Madrid, who bounced back from dropping their first points of the campaign in a disappointing home draw against Osasuna last weekend, moved on to 22 points, three ahead of rivals Barcelona who have a game in hand and will host Celta Vigo on Sunday.
“Our goal today was to win and keep the pressure now over Barcelona,” Real Madrid defender Dani Carvajal told Movistar Plus.
“We always want to score more, but the good thing today was our effort in defence.
“To not concede a goal was really important and helped us to get to the objective that was get back to winning ways.”
After conceding a goal in each of his first seven starts for Real Madrid, goalkeeper Andriy Lunin kept his first clean-sheet for the Spanish giants.
After the early goal, Real piled on the pressure.
Rodrygo, who played centre forward in place of Karim Benzema, who was rested by Madrid coach Carlo Ancelotti ahead of next weekend’s El Clasico against Barcelona, was the focal point of Real Madrid’s attack.
“The clean sheet is very important,” Ancelotti said. “The success we had last year was because the defensive aspect was very good, and tonight as well.
“It’s important like every game. The Clasico is still far off, we have another game first. I’ve rested some players like Benzema and [Ferland] Mendy. On Tuesday I’ll rotate a bit more.”
Rodrygo missed a great chance with a close-range header and Modric, who was returning after missing two games with a hip injury he suffered on international duty with Croatia, fired a bullet-shot wide from the edge of the box.
Real Madrid were also denied a penalty just before the break, when Vinicius Jr was fouled inside the box but a VAR check spotted that the ball had gone out on the left touchline in the build-up.
Rodrygo shot wide immediately after the break and, two minutes later, Getafe goalkeeper David Soria made an incredible stop to deny a bullet-strike from Tchouameni from inside the box.
The Brazilian had a goal ruled out a few minutes later after the VAR decided he was narrowly offside.
The pace of the game dropped as Real controlled possession and a helpless Getafe defended with 11 men in their own half.
Getafe have lost two straight games and are 16th on seven points, two above the relegation zone.
Information from ESPN’s Alex Kirkland contributed to this report.