- Juan Foyth (26')
- Alexander Sørloth (40')
- Álex Baena (50')
- Gavi (12')
- Frenkie de Jong (15')
- Ferran Torres (68')
- Robert Lewandowski (71')
Barca took an early two-goal lead after Gavi and Frenkie De Jong scored within two minutes of each other, but the hosts recovered with first-half goals by Juan Foyth and Alexander Sorloth, and from Alex Baena five minutes after the break.
Barca substitute Ferran Torres struck from close range to level the match again in the 68th minute, with Lewandowski tapping-in from a rebound off the post a little later, to give them a hard-fought win in a pulsating affair.
"It was a crazy game, which was our fault," Barca boss Xavi Hernandez said after the match. "We were dominating at 2-0, although Villarreal had started well early on. From there, though, the game was ours; then we give up too much.
"Their first goal is our fault, they can't score like that from a corner. The second goal is avoidable. The third is a counterattack ... From there, we played well. The team was patient, dominated and created a lot.
"In the end, I think we could have scored two or three more. I am satisfied, above all with the second half and how we attacked, but we have to improve defensively."
- Alejandro José Hernández Hernández