The Argentine, 33, achieved the feat with a diving header just before half-time, immediately after his penalty was saved by keeper Jaume Domenech.
Messi scored his first goal for Barca in 2005 against Albacete.
Pele scored 643 goals in 19 seasons for Brazilian side Santos between 1956 and 1974.
Sadly for Messi, his celebrations will likely be muted after Barcelona failed to beat their mid-table opponents.
The result leaves the 26-time champions fifth in La Liga, eight points behind Atletico Madrid, who earlier defeated Elche 3-1 to move to 29 points.
Fierce rivals and champions Real Madrid, five points ahead of Barca, play Eibar on Sunday.
This should have been Barcelona’s third league win on the bounce, having led 2-1 in the second half and grown stronger as the match progressed.
They were given an almighty jolt in the 29th minute when defender Mouctar Diakhaby gave the visitors the lead when he headed in from a corner after being left unmarked.
The action from the Nou Camp as it happened
Valencia had defended well up to that point and felt aggrieved that Barcelona were awarded a penalty just before half-time when Jose Gaya was judged to have pushed Antoine Griezmann over in the area.
After the referee Alejandro Hernandez confirmed the foul following a check of the pitchside monitor, Messi stepped up for what should been his historic moment. However, Domenech made a brilliant save only for the Argentine to then nod home at the far post seconds later.
Barcelona were on top for much of the second half and penetrated the last line of defence once more when Uruguayan defender Ronald Araujo produced an outlandish scissor-kick which beat the reach of Domenech.
Ronald Koeman’s men were desperate to kill the game off with another goal, but as they pressed they were caught by a Valencia counter-attack, which resulted in the deadly Maxi Gomez poking in at the far post.
The 24-year-old Uruguay striker has now been involved in at least one goal in six of his seven La Liga games against Barcelona.
Ex-Liverpool midfielder Philippe Coutinho went close with an angled strike 12 minutes from time, but that was as close as Barca got to scoring again in the closing stages.