Barca dominated possession for the first 25 minutes, but were stunned when Odion Ighalo put the hosts ahead at the Estadio Nuevo Los Carmenes.
Messi tapped in a deserved equaliser five minutes into the second half, though, and then curled in a free-kick 17 minutes from time to complete the turnaround and move Barca 15 points clear at the summit.
A first half goal by Javier Saviola earned Malaga a 1-0 victory over Athletic Bilbao to ensure they will remain fourth in the table by the end of the weekend.
Lucas Piazon, on loan from Chelsea until the end of the season, made his first start for Malaga and marked the occasion by providing the assist for the only goal of the game.
The 19-year-old used skill and strength to advance into the Athletic area and pulled a pass back from the by-line into the path of Saviola near the penalty spot and the striker shot high into the net after 18 minutes.
Celta Vigo remained in the relegation zone after suffering their third defeat in a row away with a 3-1 loss to Getafe.
All the goals came in a frantic first half. Adrian Colunga opened the scoring for the hosts after 10 minutes but Augusto Fernandez equalised just 10 minutes later, before Diego Castro and then Federico Fernandez added goals of their own before the break.
An early goal by Kike Sola saw Osasuna earn themselves some much-needed breathing space from the relegation zone with a 10 win over rivals Real Zaragoza.
Atletico Madrid are in action at Real Valladolid, on the same night that third-placed Real Madrid - who trail them by four points - are at home to Rayo Vallecano.
Most of sixth-placed Rayo's rivals for the other Champions League berth also play on Sunday, with fifth-placed Valencia facing second-bottom Real Mallorca at the Mestalla, seventh-placed Real Sociedad hosting Levante and Real Betis, in eighth, travelling to Espanyol.
On Friday, Deportivo La Coruna fell to a 3-1 defeat at Sevilla to remain adrift at the foot of the La Liga standings.
Fernando Vazquez took over during the week with the tough task of steering the Galician side to safety, and he got a first-hand look of how much work there is to do as Deportivo quickly fell behind on the road to Ivan Rakitic's fifth-minute goal.
Gary Medel got another in the 27th minute and although Ivan Riki soon replied for Depor, any hope of a comeback was quickly snuffed out by Medel's second.
Saturday's La Liga Results
Sunday's La Liga Fixtures
Friday's La Liga Fixture