After Angel di Maria's intended cross had found the back of the net to give Madrid the lead just after half-time, the Welshman was introduced for the final 13 minutes on his return from a thigh injury.
And it was Bale who was brought down by Weligton in stoppage time to allow Cristiano Ronaldo to seal the three points from the penalty spot. It was a much improved all round performance from Madrid, who were only denied a far more comfortable margin of victory due to a series of wonderful saves by Malaga keeper Willy Caballero.
Despite his return to fitness, Bale was left on the bench by Carlo Ancelotti due to his lack of match practice.
An injury to Karim Benzema also gave Alvaro Morata his chance to start and the Spanish under-21 international was highly involved in the first period as Madrid did everything but score.