Barca need two more points to wrest the league crown back from their arch rivals and secure a fourth title in five years and a win at third-placed Atletico Madrid on Sunday would be enough for Tito Vilanova's side.
Barca have 88 points from 34 of 38 matches, with Real in second on 80 from 35. Atletico, eight points further back in third, secured a berth in the Champions League group stage with a 3-1 win at struggling Celta Vigo earlier on Wednesday.
Both matches had been brought forward due to the King's Cup final between Real and Atletico on Friday May 17.
Real coach Jose Mourinho, who seems certain to leave after a disappointing season, was again whistled by a significant section of the home support at the Bernabeu when his name was read out before kick-off.
The Portuguese has clashed with several members of the squad in recent weeks, including club captain Iker Casillas, who was again left out of the team, and fans cheered when the Spain goalkeeper's name was read out in the list of substitutes.
Malaga's Chilean coach Manuel Pellegrini, whom Mourinho replaced when he joined from Inter Milan in 2010, was also given a warm reception.
"The fans do what they think is right," Mourinho's assistant Aitor Karanka told a post-match news conference.
"And the coach does what he thinks is right to get the best performance from the team to win matches," he added.
Centre-back Raul Albiol nodded Real in front from a corner in the third minute before Roque Santa Cruz, who scored in Malaga's 3-2 home win against Real in December, levelled after a quarter of an hour.
The match turned in the 21st minute when Malaga defender Sergio Sanchez was shown a straight red card for bringing Ronaldo down in the area.
Although the Portuguese had his spot-kick saved by Willy Caballero, who injured his ankle in the process and had to be replaced by Carlos Kameni, Ronaldo netted with an indirect free-kick close to goal in the 26th minute.
It was his 200th goal on his 197th appearance for Real since joining from Manchester United for a record fee in 2009 and his 34th in La Liga this season.
Mesut Ozil finished off a swift breakaway to make it 3-1 to Real in the 34th minute, Vitorino Antunes pulled a goal back for Malaga two minutes later and Ronaldo set up Karim Benzema to make it 4-2 on the stroke of half-time.
The second half was much less eventful until Luka Modric struck a long-range shot in off a post in the 63rd minute.
Malaga centre-back Martin Demichelis was shown a second yellow card for a 73rd-minute foul on Ronaldo and sent off and Ozil then went over awkwardly with around 10 minutes left and appeared to injure his right knee.
The German international was carried off on a stretcher for treatment, reducing Real to 10 men as they had already made their three substitutions.
The stadium was emptying when substitute Angel di Maria completed the rout in added time with a curling shot into the corner from the e
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.