The hosts looked to be on their way when Pedro opened the scoring after just seven minutes when he netted from close range after Thierry Henry's shot had come back off the woodwork.
But the Yellow Submarine failed to read the script and David Fuster levelled for the visitors within six minutes of the restart, sweeping the ball home at the far post following a cross from the right.
Zlatan Ibrahimovic missed a great opportunity for the hosts late on, but it was not to be.
"It is a lesson for the future - it will make us stronger and make us realise that everything is difficult," he said after the match.
The Barca coach believes his side were unlucky to face such a big team straight after the winter break.
"It was a very hard game and to come back from holiday and have to face one of the big clubs, Villarreal, makes it even more complicated.
"We knew the difficulty of it, but now we have to recover in exactly the same way as if we had won or lost," he said.
Guardiola also had some words of warning for striker Ibrahimovic, who was booked for a nasty lunge on Javi Venta with two minutes left and is now suspended for next week's visit to Tenerife.
"He is temperamental, but he has to be careful because some day he could leave us with 10 men on the pitch," he said.