Cristiano Ronaldo scored the winner midway through the first-half, but Los Blancos were forced to hang on in the final stages as Malaga pressed hard for an equaliser.
"You can't always win 2-0 or 3-0. I am happy because the team showed solidity, a good attitude, worked together and knew how to suffer," said the Italian.
"I don't think it was our worst game in recent times. As I said, our play wasn't spectacular, but we made up for that with other things.
"We had chances to kill off the game, we failed with the final pass a lot of times. It was a normal game against a team with a lot of desire as all the teams have at this time of the season.
"We need to value how well Malaga played too. They worked very hard and pressed well."
The victory sets Real up nicely for next weekend's visit of Barcelona to the Santiago Bernabeu.
Ancelotti's men currently lead Barca by seven points, although the Catalans can cut that gap back to four points with a win at home to Osasuna on Sunday.
And despite not being at their best at La Rosaleda, Ancelotti believes his side are ready for the challenge posed by the Spanish champions.
"I am happy because at this time of the season all the games are important. To win here wasn't easy and we have managed to do it.
"There are games when you have to show other qualities. I think we are ready for the Clasico."
Defeat for Malaga leaves them still just three points above the relegation zone amongst a group of four teams on 29 points.
Their boss Bernd Schuster believed his side deserved more out of the game, but is hopeful they can take encouragement from their performance into the last 10 games of the campaign.
"We deserved a happier ending because we matched them.
"Against the top teams we just lack that final play to score a goal, but we showed heart.
"We need to overcome the quality of the opponent with our fight and we will keep going until the end."