Both teams had opportunities in the first half, but Colombia went into the break ahead after Oscar Perea released Jordan Barrera, whose pass found Villareal to open the scoring.
Spain hit back in a frenetic eight-minute spell, with Jan Virgili equalising from a precise Jesús Fortea cross before Rayane Belaid fired high into the net.
The youngster responded immediately, finishing an exquisite through ball from Jhon Renteria to restore Colombia’s lead.
Both goalkeepers were tested in the second half, with Spain’s Fran Gonzalez producing key saves. Yet Villareal completed his hat-trick, exploiting a defensive mix-up to slot home the winner, sealing a memorable victory for Colombia.
