Real went into the game without the injured Gareth Bale and Keylor Navas, whilst Isco and Luka Modric were rested with one eye on the Champions League in midweek.
Getafe’s game plan was obvious from the off, with the hosts looking to hold their discipline before countering at pace.
A few early ventures into the Real half came to nothing, whilst the main threat from the visitors came from the impressive Lucas Vazquez down the right.
The Spanish international regularly got past his man, only to see another blue shirt to appear to block his cross.
Vicente Guaita put in a fine performance for Getafe, with his first real save coming after 11 minutes when he leapt away to his right to keep out a volley from Cristiano Ronaldo after fine work from Karim Benzema.
The hosts lost Alvaro Jimenez to injury early on but that didn’t dampen their spirit.
Jorge Molina had a chance to open the scoring when Kiko Casilla went walkabout but his header went high and wide.
Guaita had to be alert on the half-hour mark as a low cross from Vazquez looked to find the awaiting Ronaldo and Benzema but the stopper was there to claim the ball.
Real almost handed the hosts the initiative when Marcelo was robbed of the ball in his own defensive third. Fajr crossed and Nacho had to be alert to put the ball over his own crossbar under pressure from Molina.
Real knitted a few passes together shortly afterwards with Llorente’s pass to Ronaldo being redirected into the path of Benzema with a cute flick but the Frenchman’s effort was deflected over.
The No 9 had no such problems minutes later though as he gave Real the lead. The hosts made a mess of a free kick and allowed Real to counter.
An attempted interception served only to play the ball into Benzema’s path and the Frenchman nudged the ball past an onrushing defender before keeping his cool to slot low past Guaita.
That goal gave Real the lead at the break and they could have extended that shortly after the restart but for more good work from Guaita.
The home goalkeeper was quickly out to smother Ronaldo as he looked to latch onto Benzema’s cross from the left, before he recovered to keep out Marcelo’s follow-up.
Real were made to regret that miss as Molina brought the hosts back level after 56 minutes.
Fajr got in behind Marcelo down the right and his low cross was deflected into the path of Molina who converted from close-range.
That goal revitalised the home side who then enjoyed a spell of pressure but without really creating anything of note.
Ronaldo fired a free kick just wide as Real went in search of a winner but he should have done much better after 73 minutes.
A deep free kick was headed back across goal and into the patch of the Portuguese who somehow contrived to stab the ball wide from four yards out when under no pressure and with the goal gaping.
His blushes were almost spared by team-mate Theo Hernandez within 60 seconds as the substitute had the ball in the net but the defender was rightly flagged for offside.
Fajr could have given the hosts the lead late on but he could only drag his effort from the edge of the box wide when he should really have tested Casilla.
He was made to regret that miss when Ronaldo banished his earlier demons with just five minutes remaining.
Isco's beautifully weighted ball over the top was perfect for the Portuguese, who let the ball drop before firing low into the far corner from 12 yards for his first league goal of the season.
Getafe could have claimed an unlikely point as Bergara and Lacen both fluffed their lines in the dying moments but in the end Real did just enough to seal three points.