Barcelona maintained its La Liga lead with a thrilling 3-2 win over Villarreal following a strong second-half comeback and an opponent's red card.