The Blues were the first to threaten when Andrew Shinnie found the run of Thomas in the box with a reverse pass, but the striker could only fire his effort over the bar.
Shinnie plunged forward through the midfield to carve out an opening for himself and he fired at goal from 25 yards, but his effort sailed just over the bar.
The home side took the lead just before the break when Thomas reacted quickly to turn the ball into the net after Paul Robinson had been denied with a header from close range.
In the second half, Maikel Kieftenbeld threaded a through-ball into the path of Thomas, who came inches away from giving his side a goal as he put his strike narrowly wide of the post.
Gillingham came close to finding an equaliser as Mitch Hancox's header rolled into the path of Ben Williamson, who poked an effort towards the bottom corner only to see his shot go inches wide.
The home side secured their victory in the 72nd minute when David Davis played a through-ball for Thomas to latch on to and he made no mistake firing past Stuart Nelson.