Real opened the scoring in the 14th minute when Turkish youngster Arda Guler slotted home a low strike off a Brahim Diaz pass before Joselu doubled the lead with a close-range header on the half-hour mark.
Sorloth pulled one back for Villarreal with a towering header in the 39th minute, but Lucas Vazquez restored Real's two-goal advantage only a minute later before Guler made it 4-1 in the final seconds of the first half.
But the hosts rallied after the break, with Sorloth scoring three goals in eight minutes, between the 48th and 56th, as he reached 23 league goals this season.