Match ends, Valencia CF 0, Barcelona 1.
Sergio Busquets scored with virtually the last kick of the game to get Barcelona back within two points of league leaders Real Madrid.
Barcelona looked set to lose ground in the title race but deep into injury time Lionel Messi set up Busquets to net his first goal for 14 months.
Valencia slip to fifth in La Liga after their first home defeat of the season.
Messi was struck on the head by something seemingly thrown from the crowd during the celebrations.
He was pictured rubbing his head afterwards, but appeared to be unhurt.
It was a win that for so long looked unlikely, with Barcelona coach Luis Enrique having selected both Busquets and Javier Mascherano in central midfield, and the visitors suffered from a rare lack of creativity.
But Busquets justified the decision in dramatic style, following up to volley home from close range after Diego Alves had saved Neymar's header from a Messi cross.
Former Liverpool striker Luis Suarez had earlier missed Barcelona's best two opportunities and also had an effort incorrectly ruled out for off-side when turning in an attempted Dani Alves shot.
Valencia, who have not beaten Barcelona at home since 2007, had chances of their own to win it but for the second successive home game were unable to score.
In the final minute of the first half, Andre Gomes rounded Barcelona goalkeeper Claudio Bravo but shot into the side netting from a tight angle.
After the break the home side had further chances to damage Barcelona's title prospects but Gerard Pique cleared off the line from Rodrigo.
With 20 minutes to go Bravo saved from Sofiane Feghouli and then thwarted on-loan Manchester City striker Alvaro Negredo.
And Valencia were denied even a point when Busquets became the unlikely match-winner, sparking celebrations which saw Messi booked after he was hit on the head by an object as Barcelona players celebrated the dramatic winner.
- 1Alves Carreira
- 19BarragánBooked at 20mins
- 5MustafiBooked at 27mins
- 23OtamendiBooked at 90mins
- 31Gayá Peña
- 10ParejoSubstituted forAugustoat 84'minutes
- 18Fuego Martínez
- 21André Gomes
- 7NegredoSubstituted forAlcácerat 82'minutes
- 17RodrigoBooked at 70minsSubstituted forde Paulat 72'minutes
- 13Rodríguez Oterino
- 20de Paul
- 22Alves da Silva
- 3PiquéBooked at 20mins
- 24MathieuBooked at 8minsSubstituted forRakiticat 69'minutes
- 18AlbaBooked at 29mins
- 6HernándezSubstituted forRafinhaat 80'minutes
- 10MessiBooked at 90mins
- 9SuárezSubstituted forPedroat 80'minutes
- 1ter Stegen
- 31El Haddadi
- David Fernández Borbalán
- Shots on Target
Second Half ends, Valencia CF 0, Barcelona 1.
Lionel Messi (Barcelona) is shown the yellow card.
Goal! Valencia CF 0, Barcelona 1. Sergio Busquets (Barcelona) left footed shot from very close range to the centre of the goal following a corner.
Attempt saved. Neymar (Barcelona) header from very close range is saved in the centre of the goal. Assisted by Lionel Messi.
Corner, Barcelona. Conceded by Filipe Augusto.
Corner, Barcelona. Conceded by Antonio Barragán.
Attempt missed. Dani Alves (Barcelona) right footed shot from outside the box misses to the left following a corner.
Corner, Barcelona. Conceded by Nicolás Otamendi.
Attempt blocked. Lionel Messi (Barcelona) left footed shot from the left side of the box is blocked.
Foul by Rafinha (Barcelona).
Javi Fuego (Valencia CF) wins a free kick in the defensive half.
Dani Alves (Barcelona).
Paco Alcácer (Valencia CF) wins a free kick in the attacking half.
Lionel Messi (Barcelona) wins a free kick on the right wing.
Foul by José Gayá (Valencia CF).
Substitution, Valencia CF. Filipe Augusto replaces Daniel Parejo because of an injury.
Substitution, Valencia CF. Paco Alcácer replaces Álvaro Negredo.
Corner, Barcelona. Conceded by Álvaro Negredo.
Attempt blocked. Lionel Messi (Barcelona) left footed shot from outside the box is blocked.