The best chance for Real in the first half came from Vinicius Junior, but his swift poke from right in front of goal was parried away by Getafe keeper David Soria to keep the things level in a scoreless opening 45 minutes.
It was more of the same in the second half as the hosts struggled to find a crucial go-ahead goal and were bailed out when Dani Carvajal was fouled in the penalty area in the 78th minute.
Sergio Ramos stepped up and calmly converted the spot kick -- his ninth goal of the season -- sending Soria the wrong way to put Madrid in position to see out the game.
Of Ramos' role with the team, Zidane said: "Our captain is our captain, our leader on and off the pitch. He's a one-off, he's unique. We know what he transmits to the others. When it's time to take a penalty, he has a lot of confidence."
The late strike felt harsh on Getafe, who had squandered a couple of chances to take the lead, but Zinedine Zidane's side once again saw out a difficult game to capitalise on Barca's 2-2 draw with Atletico Madrid on Tuesday.
After the match, Zidane had kind words for their opponents: "Yes, for sure, or the most difficult we've had since the return. The game against Espanyol was really complicated and again here. That's why we love this league in Spain because you never know what might happen."
Real Madrid, who have not won the title since 2017, have now recorded 17 clean sheets in league play this season, their most in a single campaign over 1994-95.
"Today was like a final for us and that's how we approached it," said Carvajal. "Getafe caused us plenty of problems, particularly in the first half but we put in a serious performance and are delighted to be taking the three points home with us."
The result means Real now lead Barcelona by four points and have a superior head-to-head record in La Liga with five matches left to play in the 2019-20 campaign.