Andy Booth struck twice as Huddersfield made it three wins in four games.
Luke Beckett gave Huddersfield the lead after three minutes when he headed home Danny Schofield's cross.
Booth doubled the lead five minutes later when he headed in Chris Brandon's cross, but Gary Mulligan pulled one back for Gillingham after 70 minutes.
But Booth made sure of the points with eight minutes left, scoring from close-range after Beckett had flicked on a Schofield corner.
Huddersfield: Glennon, Holdsworth, Nathan Clarke (McCombe 72), Mirfin, Skarz, Brandon (Young 46), Taylor-Fletcher, Collins, Schofield, Booth, Beckett.
Subs Not Used: Eastwood, Ahmed, McAliskey.
Booked: Nathan Clarke, Taylor-Fletcher.
Goals: Beckett 3, Booth 8, 83.
Gillingham: Larrieu, Sancho, Chorley, Johnson, Jackman, Southall, Flynn, Crofts, Jarvis, Mulligan, McDonald (Ndumbu-Nsungu 74).
Subs Not Used: Collin, Cox, Easton, Spiller.
Booked: Crofts, Southall, Jackman.
Goals: Mulligan 70.
Att: 9,167.
Ref: D Drysdale (Lincolnshire).