The Frenchman opened the scoring after 26 minutes at Turner's Cross, finding the near post with a strike from close range.
Graham Dorrans doubled the visitors' advantage just before the break, thumping home with a fierce drive.
Steve Clarke's side found the net twice in two minutes early the second half, courtesy of finishes from strike duo and Anelka and Shane Long, who was made captain for the evening against his former club.
Anelka then rounded off his hat-trick just before the hour mark, before Dorrans got his second of the night with a measured finish.
Clarke's men kept a clean sheet despite a host of changes in the closing stages to keep their strong pre-season form intact.