Sergio Busquets broke Valencia hearts with a goal deep into stoppage time to steal a 1-0 win for Barcelona on Sunday.
Luis Enrique's team appeared set to lose further ground on La Liga leaders Real Madrid, who chalked up a club-record 16th consecutive win across all competitions against Malaga on Saturday.
But Busquets smashed home to rescue a largely laboured performance after Diego Alves blocked Neymar's header from Lionel Messi's chipped cross.
The game ended on an unsavoury note as Messi was struck by an object that appeared to be thrown from the Mestalla stands as Barcelona celebrated the winning goal, but the Catalan club can reflect on a hard-earned triumph that leaves them two points behind Real.
Barca were indebted to goalkeeper Claudio Bravo for fine saves that denied Valencia duo Sofiane Feghouli and Alvaro Negredo before Busquets' first La Liga goal for 14 months provided a sting in the tail.
Valencia coach Nuno Espirito Santo responded to last weekend's loss against Levante by replacing Carles Gil and Pablo Piatti with Dani Parejo and Feghouli in his starting XI.
Opposite number Luis Enrique elected an unusually robust Barcelona midfield featuring holding duo Busquets and Javier Mascherano, while former Valencia defender Jeremy Mathieu was preferred to Marc Bartra at centre-back.
The Mestalla faithful enjoyed Mathieu's eighth-minute booking for a late hack through Negredo, but the Frenchman was on hand to clear when Bravo awkwardly parried a Rodrigo shot three minutes later.
Barcelona's all-star attack was largely isolated from their midfield, but Messi wonderfully brought down Gerard Pique's lofted pass for Luis Suarez to fire too close to Diego Alves in the Valencia goal.
Nicolas Otamendi made a last-ditch tackle to deny Neymar, although the Valencia defender blotted his brilliant work by reacting theatrically to a subsequent clash with the Brazil forward - prompting a melee that saw Pique and Antonio Barragan booked by referee David Fernandez Borbalan.
Parejo blazed over from a corner after half an hour and Andre Gomes curled a shot narrowly wide before Valencia strung together their best move of the first half in stoppage time.
A brisk counter-attack concluded with Rodrigo's throughball picking out Gomes, although the midfielder had to work with an acute angle having rounded Bravo and shot into the side netting.
Valencia made the brighter start to the second half - Negredo heading a cross from Jose Gaya past the post - before Suarez endured further woes in front of goal.
The Uruguay international was off target with a free header from a 56th-minute corner before muscling in between Otamendi and Diego Alves and swivelling to blast wide.
Back came Valencia and Pique was on hand to clear a Rodrigo strike off the line after Barcelona failed to effectively deal with a succession of crosses.
Messi dropped deeper to try and spark his mis-firing team and laid the ball on for Neymar to send a 20-yard effort whistling wide in the 66th minute.
Suarez's moment of frustration arrived shortly afterwards, instinctively turning home when Dani Alves steered a volley across the box, and Barca then required heroics from their goalkeeper.
Bravo thwarted Feghouli with his legs and was at full stretch to push out Negredo's rasping 78th-minute strike and ensure Busquets could send his team-mates into next weekend's local derby against Espanyol on a winning note.comments