Messi headed in from Jordi Alba's cross after his first-half penalty was saved to equal the mark set by the Brazilian great Pele for Santos.
Lionel Messi has scored his 643rd goal for Barcelona to equal Pele's record of goals for a single club as the Spanish giants were held 2-2 by Valencia.
But Messi was left frustrated as a dogged Valencia forced a draw that leaves Barcelona eight points behind leaders Atletico Madrid, who beat Elche 3-1 earlier in the day.
Barcelona started slowly and went a goal behind to Mouctar Diakhaby's unchallenged header from a corner after half an hour.
Goal on rebound
Antoine Griezmann earned the penalty that led to Messi's record-equalling goal when the Frenchman was nudged over by Jose Gaya.
Messi's spot-kick was saved by Jaume Domenech but the ball rebounded and from Alba's dinked cross, the Argentine headed the ball into the net to draw level with Pele.
Barcelona went ahead thanks to a superb scissor kick from Uruguayan Ronald Araujo.
But Valencia's pressure was rewarded when Maxi Gomez got in front of Barca central defender Oscar Mingueza to turn in a cross and equalise.
Philippe Coutinho drove a shot just wide with 12 minutes remaining and Messi curled a free-kick wide but Barcelona were forced to share the points.