With Barca looking like they might drop points for only the fourth time this season, the Argentina forward struck a low shot in the 77th minute at the Mestalla that spun just inside the post off the outstretched arm of goalkeeper Vicente Guaita.
Messi's league leading 27th goal lifted Barca to 71 points from 26 matches. They have now won 12 of 13 away games, drawing last month at Sporting Gijon in their only slip-up on the road.
They are also unbeaten in their last 20 away matches, beating a La Liga record set by Basque club Real Sociedad at the end of the 1970s.
Real Madrid can trim the gap to seven points with a win at Malaga on Thursday, when the Andalusian club's coach Manuel Pellegrini returns to the Bernabeu to face the man who replaced him at Real at the end of last season, Jose Mourinho.
Another of Pellegrini's former clubs, Villarreal, breathed life into their bid for a place in next season's Champions League earlier on Wednesday when Giuseppe Rossi struck to give them a 1-0 home win over promoted Hercules.
The Italy forward sped on to Cani's through ball in the 21st minute at the Madrigal and finished past Juan Calatayud to lift Villarreal to 50 points from 26 matches, one behind Valencia.
Juan Carlos Garrido's Villarreal side, who are still alive in the Europa League, had lost two and drawn two of their last four league matches.
Messi should have put Barca ahead in the ninth minute at a noisy Mestalla in Valencia when he was denied three times in quick succession by some desperate defence.
He had another great chance when he was clean through in the 31st but his chipped effort landed on the roof of net and he also skewed a shot just wide of goal early in the second half.
Valencia, who had hassled and harried the Barca players impressively throughout the match, had several good opportunities of their own but Pablo Hernandez and substitute Roberto Soldado were unable to convert.
Barca's Brazilian defender Adriano, who provided the assist for Messi's goal when he cut in from the left wing, said his team had been made to work hard for the three points.
"It was our most difficult away game, together with the (Real match next month), but the work is not over," he said in a television interview.
"We have to work a lot to win the championship," he added, with an eye on Barca's games at Sevilla on March 13 and at Villarreal on April 3.
Europa League champions Atletico Madrid and Athletic Bilbao stumbled in their campaigns for a European berth.
Atletico were held to a 1-1 draw at city rivals Getafe and Bilbao squandered the lead to lose 2-1 at Real Zaragoza.
Atletico are eighth on 35 points, three behind Bilbao and Sevilla, who beat visiting Sporting Gijon 3-0 on Tuesday.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.