Fit-again Kaka stepped off the bench to slide home a Ronaldo pass late on to record his first goal since last season.
He told Real's website: "To return to the Bernabeu and score was such a special moment. It had been a long time since I scored, so it was a very important goal to me.
"I would like to thank the fans for such a warm welcome after all the problems I had. It was all worth it."