Barcelona's ninth consecutive league victory provisionally reduced league leader Real Madrid's advantage to three points before Valencia's visit on Sunday.
The European champions host Real Madrid in three rounds in a "clasico" match that will likely go a long way to deciding the league crown.
"We just have to persevere," Barcelona coach Pep Guardiola said. "This was a complicated and dangerous game, and we are proud to have won here after a hard week with games against AC Milan and Athletic Bilbao."
A scrappy Zaragoza deservedly went ahead through Carlos Aranda's goal after half an hour. But Barcelona captain Carles Puyol quickly leveled for Barcelona and Messi grabbed the lead for good in the 39th with a brilliant individual effort.
Zaragoza played the second half a man down, and Messi scored a penalty in the 86th to become the first player to score 60 goals in a major European league since Gerd Mueller had 67 for Bayern Munich in 1972-73.
Messi then set up struggling teammate Pedro Rodriguez in stoppage time to seal the win at La Romareda Stadium.
The three-time world player of the year has scored 38 times in league play, giving him one more goal than Cristiano Ronaldo as the two stars duel to break the Madrid forward's league record of 40 from last season.
"We knew it would be a hard game with Zaragoza showing good form after three wins in a row, but we played a complete game to get the win," Puyol said. "Our obligation is to fight for each match."
The four goals took Barcelona's campaign tally to 161 in all competitions, a record for the Catalan side under Guardiola during his highly successful term.
Also, Miguel "Michu" Perez scored his 14th and 15th goals of the season to help Rayo Vallecano to a 6-0 rout of Osasuna.
Real Betis beat Villarreal 3-1 to remain four points from the drop, Carlos Vela netted twice to give Real Sociedad a 2-2 draw at Espanyol, and last-place Sporting Gijon lost 2-0 to Getafe.
Barcelona struggled early on, and the relegation-threatened Zaragoza had the first clear scoring chances through Aranda.
The striker began by redirecting a cross off the near post. Then in the ensuing scramble, Barcelona goalkeeper Victor Valdes was whistled for fouling Angel Lafita in front of goal. But Aranda again failed to put his side ahead when Valdes judged correctly and dove to his left to smother his spot kick.
"I always try to study the opposing players, and when he went to shoot, he kept looking at me," said Valdes, who leads the league in fewest goals allowed. "The ball came low to my side and I stopped it."
Aranda, however, saw his luck turn when Valdes blocked his low strike only to have the rebound ricochet off Aranda's head and into the net.
The game swung back in Barcelona's favor thanks to an uncharacteristic mistake by goalkeeper Roberto Jimenez, one of Zaragoza's few bright spots this season.
Roberto fumbled a routine corner kick and the ball fell to the feet of Puyol, who leveled the score in the 36th.
Messi put Barcelona in front three minutes later when he latched onto Alexis Sanchez's pass, shook his marker and ripped a left-footed shot between Roberto and the near post.
Defender Abraham Minero left Zaragoza with 10 men a minute before halftime when he was booked for a second time after pulling down Alexis.
Zaragoza also had to continue on without coach Manolo Jimenez, who had guided his team to three straight wins to escape last place, when he was sent off for complaining three minutes after the restart.
Barcelona soon settled down in defense and dominated the rest of the way. Alexis was cut down in the box by Javier Paredes and Messi did not waste the penalty kick. He has scored in 11 of his last 12 games, netting 23 goals in that span.
The Argentine forward capped the rout by laying off for Pedro to score his first goal in league play since September.
Also on Sunday, it's: Levante vs. Atletico Madrid, Mallorca vs. Granada, and Athletic Bilbao vs. Sevilla.
Malaga plays Racing Santander on Monday to close round 31.