Lacklustre Barcelona looked set to drop points after Luis Suarez equalised at the end of a breathless 10-minute spell in the second half, but Messi’s controversial penalty gave the Catalans all 3 points.
Meanwhile, referee Alberto Undiano Mallenco was talk of the match as he rubbed Valencia of two penalties and also not sending Barcelona’s Sergio Bousqet off at the Estadio de Mestalla.
Valencia’s head coach, Prandelli had called for his side to show their mettle in his first home match in charge, and they set about disrupting Barca’s early rythym in front of a noisy home crowd.
For Barca, it was Andres Iniesta’s game that ended after just 14 minutes as he jarred his leg during one robust challenge from Perez, with the Spain star applauded from the pitch by both sets of fans as he was carried off on a stretcher with clear pain in his lower right knee. Luis Enrique was incensed that Perez, who won the ball, was not even given a yellow card, but Barca responded to the blow in style as Messi gave them the lead on 22 minutes.
Ivan Rakitic, who came on for Iniesta, fed the ball to Messi just inside the area, and the Argentine blasted a shot into Alves’ bottom-left corner, although the keeper was furious that Suarez was not flagged offside as he distracted him from seeing the ball, instead he was booked for complaining.
Valencia fans frustrations grew when Samuel Umtiti escaped a penalty for a push on Rodrigo and Sergio Busquets avoided a second yellow card for a shirt pull.
But Dani Parejo should have levelled the scores before the break as he collected Rodrigo’s clever reverse pass in clear space six yards out, only for Marc-Andre ter Stegen to block him at the near post.
At the same end, Rakitic spurned a great chance to double Barca’s advantage just after half-time, slamming a rebound off the outside of the post from six yards after Alves had parried a shot from Neymar, who was making his 100th LaLiga appearance.
Valencia punished that miss with aplomb on 52 minutes, as Munir on at the interval for Martin Montoya fired a first-time left-footed shot past the static Ter Stegen after being teed up on the edge of the area by Parejo.
Just four minutes later, Mestalla was rocking as Valencia snatched the lead. Nani’s delightful chip over the Barca defence was half-volleyed off the turf and into Ter Stegen’s left-hand corner by the unmarked Rodrigo.
Valencia had another penalty appeal denied after Mascherano bundled Mangala to the ground in Barca 18-yard box when he was clear to head in corner.
The referee later made another blunder as he awarded Barcelona a late penalty after he claimed Aymen Abdennour tripped Suarez in the box and Messi made no mistake as he stepped up to slot home from the goalkeepers direction.
They may be trouble for Valencia though as fans threw up water bottle at Neymar and his teammates when celebrating Messi’s late penalty winner.