Dani Alves gave the visitors the lead before Messi scored twice to go to 80 goals in 2012, just five behind Muller's record scored in a calendar year from 1972.
Barca were beaten by Celtic in Glasgow two weeks ago, and Messi was anxious for a victory this time.
He said: "We couldn't allow what happened at Celtic to happen again.
"We knew we had to come out strongly right from the start because it's always tough to play away in this competition and even more so given the state of the pitch.
"Obviously the fact we didn't concede is a boost for everyone, especially when we have been letting in too many goals recently."
Spartak opened brightly last night and Kim Kallstrom went close. Then Pedro almost put Barca in front, but his shot was well saved by keeper Andrei Dykan, who showed quick reactions in the centre of the goal.
Barcelona went in front in 16 minutes, Alves striking a volley past Dykan after the ball was laid off by Messi.
Spartak then wasted a great chance to equalise when Emmanuel Emenike's cross from the right found Marek Suchy, but he shot high from 12 yards.
Then Barca doubled their lead. Andres Iniesta's shot brought a parry from the goalkeeper, but Messi pounced on the rebound.
Then the Argentinian scored his second of the night and Barca's third six minutes before the break when he timed his run perfectly and latched on to Pedro's pass to score.