The victory signalled the end to a difficult week for the Magpies after two defeats in a row.
Newcastle went into the game knowing they needed three points if they wanted to make a return to the top of the Championship table.
With Brighton being the pace setters after a 2-0 win over Leeds United on Friday night, the Magpies made the perfect response as Gayle fired a brace in the opening 24 minutes.
And from then, the home side never looked back as their chances in front of goal merited a higher scoreline, but that slightly forgotten about when Yoan Gouffran added a third two minutes after half-time. Gayle then grabbed his hat-trick on 77 minutes.
United made two changes from the side that suffered that cruel defeat at Nottingham Forest as Vurnon Anita and Mohammed Diame replaced DeAndre Yedlin and Ayoze Perez. Jonjo Shelvey and Paul Dummett also retained their places after their red cards were overturned.
Birmingham didn't even register a single shot on Karl Darlow's goal as the Magpies bossed proceedings and arguably could have gone into half-time with a bigger lead.
In Newcastle's 4,500th league game, their first opportunity came on seven minutes when Shelvey angled a ball into the area as Diame came closest to giving his side the lead in a mini goal-mouth scramble.
From then out, United began to build pressure as Gayle saw a low effort saved before Ciaran Clark has his header saved by Tomas Kuszczak in the 10th minute.
Isaac Hayden shook off his early knock to curl an effort just wide of Kuszczak's top corner.
Gayle can't stop scoring
And the Magpies' made their early chances count on 18 minutes when Diame done brilliantly to hold his man down the right-hand side to whip a fine delivery into the area that Gayle headed in.
Six minutes later, Gayle tapped home his second when Hayden, just like Diame, delivered a cross from the same position and United's number nine was there to supply the finish.
Rafael Benitez's men continued to stride forward as Gouffran and Matt Ritchie were next to try their luck, but to no avail.
Central midfield duo
Newcastle's central midfield duo Hayden and Shelvey shone through as both were largely involved in their side's openers. Both were playing with confidence, illustrated by Hayden's surging run into the box with Kuszczak having to make the save on 34 minutes.
Possession statistics showed that the home side ended the first-half with 68 per-cent, reflecting their dominance.
Diame also looked liked he was playing with a point to prove as the Senegalese international nearly caught out Kuszczak, who had to awkwardly parry his stinging effort over just before the break.
Magpies come out of the blocks quick
If Benitez's men fell victim to wasting opportunities in the first period, then they certainly made up for it when Gouffran fired in his side's third on 47 minutes.
It seemed the perfect start as City boss Gary Rowett made a double change at the break with Lukas Jutkiewicz and Maikel Kieftenbeld joining the action, but Gouffran immediately put the game out of sight.
With proceedings feeling slightly more relaxed, St James' Park went bright as fans used their phones as torches in a bid to maintain the atmosphere.
On the 65th minute, Diame played in Gayle. The striker looked certain to have bagged a hat-trick but Kuszczak pulled off a great save to deny him his third.
Just before the 70th-minute mark, the Blues finally managed to create a clear effort with Jutkiewicz surprisingly wasting an inviting headed opportunity.
Birmingham then proceeded to miss another great chance to get on the scoresheet when Darlow parried Che Adams' shot into the path of Corey O'Keeffe, but somehow the substitute missed the target.
Newcastle then fired a fourth as Gayle bagged his hat-trick after great work from Shelvey to set the number nine up.
As soon as the Englishman's celebration ended, he was taken off for Aleksander Mitrovic - leaving the pitch having extended his tally for the season to 16 in the league.