Carlo Ancelotti was dealt a blow before the match when world-record signing Gareth Bale suffered an injury in the warm-up at the Bernabeu, but his replacement Isco starred after Angel Lafita had given Getafe a surprise lead.
Pepe equalised 19 minutes in after Miguel Angel Moya could only parry Cristiano Ronaldo’s close-range shot, before the Portuguese forward converted a penalty to give Real a 2-1 half-time advantage.
Isco added a third with a cool finish just before the hour mark, and Ronaldo rounded off the win in style as he buried Sami Khedira's low cross with a brilliant backheel.
The win sees Ancelotti's men move up to third, two points behind leaders Barcelona and Atletico Madrid.
Elsewhere, under-fire Valencia boss Miroslav Djukic eased the pressure on himself with a 3-1 win over troubled Sevilla.
Former Valencia manager Unai Emery took his team to Mestalla bottom of the league after picking up just two points from their first four matches, and that run continued as Djukic's side ended their run of four successive losses in all competitions.
Jonas opened the scoring for the hosts 32 minutes in as he fired home a cutback from Fede Cartabia, but Kevin Gameiro equalised early in the second half as Sevilla grew into the game.
However, Jonas then netted his second 17 minutes from time before Victor Ruiz sealed their much-needed win.
Meanwhile, Sevilla's city rivals Real Betis welcomed Granada to Estadio Benito Villamarin and neither side were able to break the deadlock in a 0-0 stalemate.
Celta Vigo and Villarreal also played out a 0-0 draw in Sunday’s early fixture. Marcelino Garcia Toral’s side piled on the pressure in the closing stages, but Celta held on to claim a point.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.