The teenager was the standout performer at Camp Nou, tormenting the visitors with three superb left-footed finishes into the far corner.
His clinical display helped Barcelona move four points clear of Real Madrid, with Robert Lewandowski adding a late goal to seal the victory.
Yamal opened the scoring after being played through by Fermin Lopez and showed composure to slot past the goalkeeper.
His second was a moment of brilliance, weaving past defenders before unleashing a fierce strike into the top corner.
Villarreal briefly responded after the break, but Yamal completed his treble with a composed curled finish from Pedri’s pass, earning a standing ovation when substituted.
