The visitors dominated the contest with clinical finishing, putting the pressure on Jose Mourinho's side, who now only sit two points above them at the summit
A precise header from the Argentine put the visitors ahead, 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, who play Athletic Bilbao later on Sunday.
Despite Pep Guardiola's side's strong showing, the hosts were the more threatening side in the early going. Before 20 minutes had passed, Isco had three chances in the space of two minutes, but Victor Valdes saved each acrobatically to keep the contest scoreless.
Barca pushed forward in the ensuing minutes but could not find the crucial pass to create a clear opening on goal. That is, until Messi took control of the contest.
Iniesta played Adriano in down the left, and the Brazilian's delicate cross found the head of Messi near the penalty spot. The Fifa Ballon d'Or winner finished powerfully into the left side of the net, beating the outstretched arms of Willy Caballero.In the second half, the visitors improved, and put the contest out of sight within minutes of the restart.
Thiago's low shot was saved from the top of the box, and 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 range.
Moments after, Messi carved through the Malaga defence with a stellar run to the right side of the box, knocking the ball home with the deftest of touches.
Then, with 10 minutes to go, Messi drove from the middle of the pitch and calmly slotted into the right side of the net for his 22nd league goal of the season in just 19 appearances.
Salomon Rondon struck for the home side five minutes from time, beating Valdes low and to the left to give his side scant consolation, but Messi's magic was the abiding memory of the contest.
Up next, Malaga host Sevilla this coming weekend, while Barcelona return to action on Wednesday in the second leg of the Copa del Rey quarter-finals, where they will host Real Madrid, holding a 2-1 advantage.