The France international moved to Selhurst Park from Paris Saint-Germain for a club record fee on Friday but was not included in the squad for Palace's trip to The Hive.
While Barnet - preparing for their first season back in the Football League - found their rhythm going forward, Alan Pardew's side had enough quality to claim the victory thanks largely to Gayle's treble.
Barnet scored with their first attack of the game as John Akinde - their top scorer last season - took just 72 seconds to find the mark.
However, the Premier League side restored parity soon after, as Gayle's low free-kick beat the wall before the attacker curled home from outside the box - this time in open play.
Pardew made a host of changes at the break and saw Gayle complete his hat-trick early in the second half as he converted following a Fraizer Campbell flick-on.
Barnet made 10 changes prior to captain Luke Gambin firing home after the hour, but young Palace striker Reise Allassani showed his pace to burst clear and restore the two-goal lead with a smart finish.
The goals continued to flow as veteran striker Kevin Lisbie registered his first Barnet goal nine minutes from time, before Allassani and Kwesi Appiah set up Campbell for the final goal of the game.