The Argentine had already started celebrating in the first half at Mestalla after his shot had eluded the grasp of goalkeeper Neto.
Valencia's No. 1 let a seemingly innocuous effort slip past him, and despite scurrying back was unable to stop the ball bouncing over the line.
Messi's celebrations were cut short, however, when it became apparent the goal was not going to be given and play continued.
There was little doubt that the whole ball had crossed the line, as images from the match clearly showed.
And when the ball finally went out of play referee Iglesias Villanueva was surrounded by furious Barca players incensed at the mistake.
It is not the first time Barca have fallen victim to such an error this season.
Against Betis earlier this season a similar goal was not given despite the ball crossing the line — is it time for a VAR revolution in La Liga?