Leon Legge opened the scoring with his second goal of the season, the former Brentford defender heading in from Joe Martin's free-kick after 18 minutes.
Martin also set up the Gills' second, providing the cross from which on-loan wing back Michael Harriman was able to fire past Wes Foderingham late on.
Cody McDonald had earlier blazed wide from an acute angle for the Kent side, and Adebayo Akinfenwa should have done better with a header following Harriman's cross.
Swindon, who have not won on the road since beating Colchester on November 16, came the closest to opening the scoring when the unmarked Yaser Kasim fired straight at Gills goalkeeper Stuart Nelson from six yards.
Legge then found room to open the scoring from Martin's free-kick, but after the break the visitors had chances.
Raphael Branco saw his goalbound shot well blocked by Elliott Hewitt, and Massimo Luongo curled a 78th-minute effort straight at Nelson before Harriman sealed the victory.