Varane netted after the break with a powerful header from Toni Kroos' free kick before Modric secured the three points in added time, ahead of Madrid's trip to Saudi Arabia for the Spanish Super Cup.
Madrid needed to win this game by any means necessary after ending 2019 with three draws, two of them 0-0. Victory was the most important thing, and the way they achieved it was secondary.
This was a testing assignment to start the year. Getafe are one of the toughest teams to face in La Liga, a physical and well-organised side with genuine quality in attack under coach Jose Bordalas.
There were outstanding performances down the spine of the Madrid team -- Courtois in goal, Varane in defence and Casemiro in midfield. Only Barcelona had won at Getafe in the league this season, and Madrid now join that list.
It was a scrappy, ugly start to the game at the Coliseum Alfonso Perez, which is just how Getafe like it. Real Madrid had to find a way to play the home side at their own game.
It wasn't easy going and it often wasn't the kind of flowing football that suits players such as Kroos, Modric, Isco and Karim Benzema, but they will be delighted with the three points nonetheless.
Manager rating out of 10
7 - Zinedine Zidane made four changes to the team that drew 0-0 with Athletic Bilbao in the last game of 2019. Sergio Ramos was suspended while Vinicius, Rodrygo and (surprisingly) Fede Valverde dropped to the bench.
Valverde's physicality would have helped in the midfield battle, and his absence against Getafe of all teams was strange. Otherwise, Zidane's set-up and substitutions were hard to fault.
Player ratings (1-10; 10 = best. Players introduced after 70 minutes get no rating)
DF Dani Carvajal, 8 - Carvajal is exactly the type of player you want in your team in this kind of game. He's a fighter and against Getafe, that's just what you need.
DF Eder Militao, 8 - A big afternoon for the Brazilian, replacing Sergio Ramos, and with Getafe's handful of a forward line (with 24 goals) to deal with. Has had a slow start to his Real Madrid career but this was a highlight so far.
DF Raphael Varane, 9 - Stepped up to lead in Ramos' absence. Had a straightforward job contributing to the opener thanks to Soria's blunder, did well with the second and was impressive all-round in defence.
DF Ferland Mendy, 8 - Improving with every week that goes by. Provided the assist for Varane's opener with his wrong foot.
MF Casemiro, 8 - Back in the team having been suspended against Athletic Bilbao and his presence was noted immediately.
MF Toni Kroos, 7 - A pinpoint delivery for Varane's header, otherwise did well on a difficult afternoon.
MF Luka Modric, 8 - Finished off a wonderful breakaway move in added time to score Madrid's third.
MF Isco, 7 - Before this game Zidane admitted he identifies with Isco for his position and style of play -- but he struggled to make an impact here in a game that didn't suit him.
FW Gareth Bale, 7 - Did well, worked hard for 90 minutes and had two late chances to score in added time when being denied by a Soria save and Djene block.
FW Karim Benzema, 7 - One of his quieter games against a well-organised Getafe defence.
MF Fede Valverde, NR -- came on for Kroos to offer fresh legs in midfield and was magnificent. Should have started the game.
FW Vinicius Junior, NR - replaced Isco and enjoyed himself down the left. Had one really good chance late on but could only find the side netting.
FW Luka Jovic, NR - unable to make an impact again.