Barcelona struck twice late on to snatch all three points from a spirited Villarreal side in La Liga.
Frenkie De Jong’s close-range finish opened the scoring, but Barca were clinging on after Samuel Chukwueze’s well-taken leveler in the 76th minute.
But Memphis Depay pounced after the Villarreal defense failed to clear a long clearance in the 88th minute.
Substitute Philippe Coutinho slotted an injury-time penalty to make sure of the result and rub salt in the wound.
Barcelona remains seventh in the Spanish top-flight despite their first away league win of the season, but are now only three points from the Champions League places and seven off-leaders Real Madrid.
The win also continues new manager Xavi’s unbeaten start to his term at the Nou Camp, but there was plenty in the performance to give the former Spain midfielder pause for thought.
Villarreal frequently looked like overrunning his side in the second half with the Arnaut Danjuma and Manu Trigueros speed and movement creating a clutch of chances.
The hosts, who also saw a strong first-half claim for a penalty turned away, were left ruing their own defensive shortcoming as Colombian Pervis Estupinan allowed Depay in to round the keeper and put his side back in front against the run of play.
Former Tottenham defender Juan Foyth was at fault for the final goal, tripping Coutinho in the box to give away a clear penalty.