FC Barcelona failed to take advantage of the slip up from Real Madrid when the Galaticos did share the spoils against Athletico Madrid earlier in the day the ending the game 1-1.
However, a first-half strike from ex-FC Barcelona forward Sandro Ramirez and a late effort from Jony Rodriguez ended their hopes.
Forward Neymar, who has scored 15 goals for Barca this season in all competitions, was sent off in the 65th minute after receiving a second yellow card.
The red card was Neymar’s first of his FC Barcelona career for two bookable offences as the Catalans were left to rue letting Sandro Ramirez join Malaga for free last summer.
The Brazil international had brought down Diego Llorente with a late challenge, and then sarcastically applauded as he made his way off the pitch.
Malaga, who began the match in 15th spot, looked far more threatening, especially on the counter-attack.
Sandro exposed some awful defending from Jeremy Mathieu to sprint clear on goal and slot past MarcAndre ter Stegen at his near post in the 32nd minute to give Malaga the lead.
In the second half they had a goal disallowed when Adalberto Penaranda was wrongly flagged offside before they finally scored their second.
Pablo Fornals’ square ball found Rodriguez, who slotted in from 10 yards out.
Barca barely troubled Malaga keeper Carlos Kameni, although the Cameroonian international did make two good saves to block two firm efforts from Luis Suarez.
The defeat means FC Barcelona remain on 69 points, three behind Real who have a game in hand.
Their next league game is against Real Sociedad on April 15, before what promises to be a season-defining El Clasico at the Bernabeu on April 23.