Conor Hourihane's 30-yard wondergoal gave Barnsley the lead midway through the first half then Sam Winnall got his first for the Reds six minutes later.
There were then three goals in nine second half minutes. Substitute Devante Cole made it three, minutes into his home debut, before Gillingham were given a penalty which Adam Davies saved only for taker Danny Kedwell to tap in the rebound.
Dale Jennings restored the three-goal lead on 76 minutes as Barnsley made it seven points from three games.
Danny Wilson made one change to the side that won at Crewe and drew at Coventry last week as he gave a debut to 19-year-old central midfielder Brad Abbott in place of the injured James Bailey.
Luke Berry missed a good headed chance early on but the Reds were ahead on 24 minutes when Hourihane smashed in his superb long-ranger. This followed up the Irishman's free-kick against Coventry four days earlier.
Jermaine McGlashan had Gillingham's best chance of the half but his weak effort was saved by Adam Davies seconds before the Reds went 2-0 up. Last year's League Two top-scorer Winnall, who signed in the summer from Scunthorpe, headed in Reece Brown's cross on 30 minutes.
Winnall had two chances early in the second half as he missed a one-on-one after a defensive error then headed a corner over the bar.
Wilson made an attacking change on 65 minutes when he introduced pacy duo Dale Jennings and Cole. Manchester City youngster Cole netted three minutes later has he turned in Joe Dudgeon's cross from close range to make it 3-0.
Gillingham were given a way back into the game soon after when Dudgeon was adjudged to have fouled McGlashan in the area. Davies dived to his left to deny Kedwell but the ball bounced straight back to the striker who fired in on 73 minutes.
It was 4-1 three minutes later when Hourihane's free-kick was blocked by the Gillingham wall but the ball rolled to the unmarked Jennings who fired across the 'keeper from the left side of the box.
Substitute Kane Hemmings hit the post late on and also put a cheeky back heel just wide.
Most read sport stories