The visiting side dominated the contest with clinical finishing, putting the pressure on Jose Mourinho's side, which now only sits two points above Barca at the summit.
A precise header from the Argentine put the visiting side up 1-0, before Alexis Sanchez scored early in the second half. After the interval Messi added his second with a brilliant solo effort, doing the same 10 minutes from time to help his team pull within two points of Real Madrid, which plays Athletic Bilbao later on Sunday.
Despite Pep Guardiola's side's strong showing, the home side was the more threatening of the two in the early going. Just before the first 20 minutes had passed, Isco managed three chances in the span of two minute, but Victor Valdes saved each with acrobatic, well-timed efforts to keep the contest scoreless.
Barca pushed forward in the ensuing minutes but could not find the crucial pass to send someone through for a quality look, that is, until Messi's stunning strike.
Whit 33 minutes gone, the visitors opened the scoring after Iniesta played Adriano down the left. The Brazilian's delicate cross found the head of Messi near the penalty spot, and the Argentine finished strong into the left side of the net, beating the outstretched arms of Willy Caballero to give his side the advantage at the break.In the second half, the Barcelona improved, tripling the score after just five minutes.
In the 47th minute, Thiago had a low shot saved from the top of the box, with the ball then flying out to the left. Adriano picked it up, finding the young midfielder for another shot, but he was again denied by Caballero, before Alexis managed to fire home on the rebound from close.
Moments after, Messi carved through the Malaga defense with a stellar run to the right side of the box, knocking the ball into the left side of the goal with a little touch.
Then, with 10 minutes to go, Messi took the ball from the middle of the pitch into the left side of the box, finishing calmly into the right side of the net for his 22nd league goal of the season.
Salomon Rondon added a goal five minutes from time with a finish inside the box, beating Valdes low and to the left to give his side a consolation strike.
Up next, Malaga hosts Sevilla this coming weekend in league play. Barcelona returns to action on Wednesday in the second leg of the Copa del Rey quarterfinals, where it will host Real Madrid, holding a 2-1 advantage.