Victor Valdes made three fine saves to prevent Isco giving the hosts the lead early on, but Barca took control just after the half-hour mark as Messi gave Willy Caballero no chance with a powerful header from Adriano's cross.
And the visitors made sure of the three points with two quickfire goals early in the second half as Alexis Sanchez fired home from close range before Messi got his second of the day with a wonderful run and finish.
The Argentinian completed his treble on 81 minutes as he again left the Malaga defence in his wake before slipping the ball past Caballero from a narrow angle, but Salomon Rondon did get a consolation for the hosts five minutes later with a neat finish after Valdes had parried Recio's effort.
Before Sunday Messi had scored just once away from home all season in La Liga, but he showed his intent with the first effort of the game on nine minutes that was deflected just wide.
Soon after, though, it was Valdes who showed his worth with three saves from Isco to keep the champions level. The Spain international firstly tipped the Malaga midfielder's fine long-range effort wide and from the resulting corner got down well to parry Isco's header before smothering the rebound.
Eric Abidal scored only his second goal for Barca on Wednesday but he was nearly in for another as he was played through by Messi, but Caballero did well to force the Frenchman wide and take the ball away from danger.
The breakthrough did come for the visitors on 31 minutes and the manner of its arrival was surprising even if the name of goalscorer was not - Adriano's cross from the left met by a rare header by Messi into the bottom corner.
Barcelona had dropped points in five of their previous eight away league games this season, but they made sure there would be no slip-up this time with a stunning five-minute spell after the break.
Sanchez doubled their advantage as he tapped in after Caballero had twice denied Thiago, and then Messi won the ball in midfield and embarked on a trademark run that took him beyond compatriot Martin Demichelis before passing the ball with ease into Caballero's net.
The Ballon d'Or winner came within inches of a hat-trick as his 25-yard free-kick came back off the underside of the bar with 17 minutes remaining, but he was not to be denied another three-goal haul as he ran from the halfway line past Demichelis and Joris Mathijsen before slotting the ball past Caballero.
Malaga did get on the scoresheet with four minutes remaining as Valdes repelled Recio's initial effort only into the path of Rondon, who swept home, but it was scant consolation.