© Getty Images
The home side were held to a goalless first half, despite creating the majority of the chances in the opening 45 minutes.
The visitors created a strong attacking move just before the half-time whistle, but Eliseu's strike from close range went wide.
Carlo Ancelotti's men took the lead at the start of the second half, as Di Maria fired a cross in towards Ronaldo, but his delivery ended up in the back of the net.
The home side looked like adding to their score, but a series of saves from the Malaga keeper ensured that the visitors remained just a goal down until the latter stages of the contest.
Gareth Bale came off the bench for the last 15 minutes as Real looked to close out the win and won a penalty in stoppage time that Ronaldo duly converted.