Memphis Depay calmly dodged goalkeeper Jeronimo Rulli, to score a pivotal goal in the 88th minute, giving Barcelona a 2-1 lead, then Philippe Coutinho added the third goal from a penalty kick in stoppage time.
Barcelona raised its score to 23 points, seven points behind leaders Real Madrid, who faces Seville on Sunday.
Villarreal fought back to equalize through Samuel Chukwueze in the 76th minute, after Frenkie de Jong gave the visitors an early lead in the second half.
Villarreal, who lost at home to Manchester United in the Champions League last Tuesday, remain in 12th place and have 16 points from 14 matches.
.