Lionel Messi scored twice and missed a penalty as Barcelona came from behind to move within two points of La Liga leaders Atletico Madrid.
Ex-Arsenal man Gabriel headed Valencia in front only for Messi to miss from the spot but convert the rebound.
Antoine Griezmann put Barca ahead and Messi clipped in a trademark free-kick before Carlos Soler’s screamer gave Valencia vain hope.
Barca host leaders Atletico next Saturday at the Nou Camp.
Third-placed Barcelona are level on points with arch rivals Real but beneath them in the table because Real have won both El Clasico games this season.
A shock defeat at home to Granada last time out had left little room for error in Barca’s quest to regain the title.
And Gabriel’s thumping header just after half-time piled further pressure onto Ronald Koeman’s side.
It took a lackadaisical penalty from Messi to spark them into life.
Jasper Cillessen pulled off a tremendous save from Messi’s spot-kick only for the Argentine to pounce for the equaliser in the ensuing scramble.
Frenkie de Jong’s header was then brilliantly turned aside by Cillessen but this time Griezmann was on hand to convert from close range.
Barca’s final goal was vintage Messi, a whipped free-kick that kissed the inside of the post and nestled in the far corner.
It was arguably not the best goal of the night with Soler’s fine strike from distance almost dragging Valencia back into it, but Koeman’s team held on.