Cristian Tello had fired the hosts into the lead after just 13 minutes but Spartak refused to be overawed by their surroundings and were level 16 minutes before half-time when Dani Alves turned Emmanuel Emenike’s cross into his own net.
The home fans were stunned on the hour mark when a excellent Spartak counter-attack teed up Romulo to put the visitors in front, but Messi applied the finishing touch to two deadly crosses by Tello and Alexis Sanchez in the final 20 minutes to secure a precious three points.
Barca were hampered by another injury to one of their central defenders as Gerard Pique limped off after 12 minutes with Alex Song coming on the make his European debut for the Catalans in an unlikely central defensive pairing alongside Javier Mascherano.
However, that change did not affect their rhythm going forward early on and they were handed the lead in spectacular style as Tello cut in off the left wing and curled a perfectly measured shot into the bottom corner.
The 2011 winners then threatened to run riot as Messi came within inches of a second, but Spartak were level just before the half hour when Emenike’s dangerous cross could only be turned into his own net by Alves.
The game then settled into its original pattern with Barca probing and Spartak leaving all 11 men behind the ball, and their defensive solidity restricted the hosts to mere half-chances before the break as Sergio Busquets headed wide from a Xavi corner before Cesc Fabregas’ looping header was comfortably tipped over the bar by Andrey Dikan.
Alves had a goal disallowed moments after the restart for a marginal offside decision but the complexion of the entire game changed on 59 minutes when Dikan brilliantly denied Messi at one end and the Russians broke down the other end for Aiden McGeady to play in Romulo in to score.
The expected waves of Barcelona attacks then descended upon the Spartak defence, but the Russians were holding out well until Tello produced another piece of magic to skip past McGeady on the left and tee up Messi for the easiest of finishes.
Tito Vilanova then threw on David Villa to join fellow substitute Alexis Sanchez in a bid to find the winner and Sanchez produced the killer cross for Messi to head home his second of the evening with 10 minutes remaining.