Substitute Nico Gonzalez scored a late winner as Barcelona edged past Elche in La Liga to end their three-game winless run in all competitions.
Ferran Jutgla headed in an opener for the hosts after 16 minutes before 17-year-old Gavi grabbed his first La Liga goal with a superb solo effort.
Substitutes Tete Morente and Pere Milla then stunned the hosts as Elche scored twice in as many minutes to draw level.
But Gonzalez poked into the top corner five minutes from time to win it.
It means Xavi’s side sit seventh, three points off a Champions League spot and 15 behind leaders Real Madrid.
They are now only two points behind fifth-placed champions Atletico Madrid, who lost 2-1 to Sevilla.
Barcelona had failed to win their previous three outings, with a 2-2 draw at Osasuna last Sunday following defeats by Bayern Munich in the Champions League and Real Betis in La Liga.
Jutgla saw an effort ruled out for offside inside 90 seconds but the summer signing did not have to wait long for his first goal at the Nou Camp, heading in Ousmane Dembele’s corner.
The impressive Gavi added a second three minutes later, flicking the ball through his legs on the turn and running directly at the defence before picking out the bottom corner.