David Beckham missed an opportunity to put the home side ahead in the 51st minute when he hit the post from a free kick.
Deportivo responded by putting Madrid under intense pressure.
The visiting side shot four times at Iker Casillas' goal in the 55th minute, with Joan Capdevila's left-footed strike from a cross by Julian de Guzman forcing the eventual equaliser.
Madrid responded quickly, with Raul Gonzalez’s 58th minute headed goal from a cross by Beckham putting them ahead.
Van Nistelrooy put the result beyond doubt after 74 minutes when he controlled a poor clearance by defender Fabricio Coloccini and scored Madrid's third goal of the evening.
In the late game, Lionel Messi of Barcelona snaked through Getafe's defence to set up a third-minute goal from Ronaldinho on the way to a 1-0 win.
The Brazilian midfielder was sent off in the 40th minute after punching Getafe’s David Belenguer in the back in retaliation for receiving three bad tackles.
|Raul Gonzalez, right, scored as Real |
triumphed at the Bernabeu [AFP]
The dismissal means Ronaldinho is likely to miss the next match against Espanyol.
Also on Saturday, Villarreal won 3-2 against Valencia, taking then to sixth in the premier league and boosting its chances of qualifying for next season's Uefa Cup competition.
David Villa opened Valencia's account from the penalty spot in the 20th minute after Villarreal goalkeeper Sebastian Viera tripped him inside the area.
Diego Forlan levelled the tie for Villareal after 34 minutes and Jon Dahl Tomasson, who is on loan to the Spanish side from Stuttgart, scored when he tucked the ball just inside the right post.
Forlan struck his 17th goal of the season after 85 minutes, with Villa's second goal of the night from an injury-time free kick providing only consolation for Valencia.