This article is more than
8 year oldIvan Rakitic deflected Guilherme Siqueira's cross-shot into his own net to give Valencia a shock lead.
Santi Mina then finished a terrific move by slotting in a second goal in first-half stoppage time.
Messi ended a club goal drought of 515 minutes, but Barcelona now only lead Atletico Madrid on goal difference.
Luis Enrique's side began April with a nine-point lead over second-placed Atletico, but their season has crumbled since then, with defeat against Real Madrid in El Clasico marking the start of a dreadful run.
It was Atletico who ended Barcelona's chances of retaining the Champions League in midweek, and who drew level at the top of La Liga with a comfortable 3-0 victory over Granada earlier on Sunday.
Barca, playing the 53rd match of a draining season that included a trip to Japan in December to win the Club World Cup, looked weary and short of ideas as they attempted to fight back f-rom a 2-0 half-time deficit.
They could lose top spot if they fail to win at Deportivo La Coruna on Wednesday, with Atletico visiting Athletic Bilbao on the same night, and Real Madrid - just a point behind in third place - also in action, at home to Villarreal.
When Messi scored for Barcelona in a Champions League victory over Arsenal on 16 March, few expected he would have to wait more than a month to find the net for his club again.
The forward did score his 499th career goal in the meantime - a penalty for Argentina in a 2-0 World Cup qualifying win over Bolivia on 30 March.
But his form for Barca has dipped at the same time as their fortunes, and he has suffered his longest run without scoring for Barcelona since 2008.
Messi was denied three times in the first half as the home side cre-ated a host of chances without taking advantage.
Eventually, he did score - turning in Jordi Alba's pull-back f-rom the left - but with Barca two goals down by that stage, there was little reason for the reigning world footballer of the year to celebrate his landmark achievement.
This was some transformation for a Valencia side humiliated 7-0 on their last visit to the Nou Camp, in the first leg of a Copa del Rey semi-final on 3 February.
Pako Ayestaran, who replaced the sacked Gary Neville as manager on 30 March, put out a line-up with far more discipline and spirit than they showed on that miserable night.
Shkodran Mustafi, once part of the youth set-up at Everton, was pivotal to their victory. The German centre-back was outstanding in frustrating Barcelona's much-vaunted forward line for much of the evening - as Ayestaran's side climbed to 12th place.
Siqueira, on loan f-rom Barcelona's title rivals Atletico Madrid, also had a significant role to play for Valencia.
The Brazilian full-back broke forward on to Andre Gomes' pass and looked as if he would be credited with the opening goal as his delivery f-rom the left was fumbled in at the near post by Claudio Bravo. Television replays, though, showed that Rakitic had got the decisive touch.
Mina, who scored when the reverse fixture ended 1-1 in December, then took advantage to place Dani Parejo's through pass inside Bravo's far post as Sergi Roberto failed to track his run.
Valencia's victory, and Barcelona's troubles, could be boiled down to a tale of two players called Alves - one who started, and one who did not.
Diego Alves, the visitors' goalkeeper, rivalled team-mate Mustafi in terms of influence on the result, making a hat-trick of saves to keep out Messi, and showing sharp reflexes to deny Neymar and Rakitic too.
In the Barcelona line-up, there was no place at right-back for Dani Alves, d-ropped to the bench after a bizarre post on Instagram that made light of his team's midweek Champions League exit at the hands of Atletico Madrid.
The defender put on a wig and impersonated his girlfriend, model Joana Sanz,to give a tongue-in-cheek reaction to Wednesday's 3-2 aggregate defeat.
His replacement, Sergi Roberto, is primarily a central midfielder, and looked uncomfortable in the full-back position - which was a significant factor in Valencia's second goal.
Barcelona coach Luis Enrique: "We have to remain strong. We need to win the last five games and I know we can do it.
"We were better than Valencia in every aspect apart f-rom our finishing. We cre-ated a lot of chances but we were unlucky.
"We've d-ropped three points that we could have taken but football is like that."
Newer articles
<p>The two leaders have discussed the Ukraine conflict, with the German chancellor calling on Moscow to hold peace talks with Kiev</p>