A 50th minute strike from Valencia’s Gabriel looked to have Barca on the ropes as they tried to keep pace with leaders Atletico Madrid, but a brace from Lionel Messi either side of an Antoine Griezmann goal earned Barca all three points.
Carlos Soler scored a brilliant goal for Valencia from outside the area as full-time approached, but Barcelona were able to see out the victory.
“We know that we won’t have any easy games until the end of the season but we got the job done after the unexpected defeat to Granada. We competed today and are going to keep competing,” said Barca defender Gerard Pique.
“Today we showed we’re still in the fight, that was what we wanted to do at the start of the season and it’s to our credit that we’re still in it.”
The result put Barca on 74 points, good enough for second place in La Liga ahead of Real on goal difference and two behind first-placed Atleti.
Barcelona play Atleti in a crunch, and potentially title-deciding, fixture on May 8.
“We’re still alive,” said assistant coach Alfred Schreuder, who is taking charge of the team during Koeman’s touchline ban, which will also make him miss the game with Atletico.
“We’re not looking at the other teams, we’re only interested in ourselves and we believe our players can go on and win the league.”