In-form Jamie Cureton scored for the third time in five matches to haul Swindon out of the League One relegation zone for the first time in five months and drag Gillingham back into the dogfight.
Cureton won the game with a stunning 27th-minute strike as 10-man Gillingham's four-game unbeaten run was brought to an end.
Town goalkeeper Rhys Evans' long clearance was flicked on by former Sheffield Wednesday striker Lee Peacock.
The revitalised Cureton unleashed a superb right-foot volley and lobbed the ball over Gillingham goalkeeper Jason Brown and into the top left-hand corner.
The visitors' hopes of turning the game round suffered a setback when striker Darren Byfield was harshly sent off four minutes into the second half.
Byfield was given his marching orders after appearing to head the ball out of the hands of Evans.
Gillingham could have been down to 10 men as early as the 36th minute when Welshman Brown escaped with only a yellow card after handling the ball outside his area.
Cureton, who has found his form after a spell on-loan at promotion-chasing Colchester, enjoyed a lively afternoon.
The former Reading frontman had his first sight of goal when he volleyed just over Jason Brown's crossbar in the 13th minute.
Cureton should have doubled his tally in the 33rd minute after Gillingham's defence had failed to deal with another Evans long ball, but the goal hero blazed over the crossbar with only Jason Brown to beat.
Jason Brown then pulled off a fine reaction save to keep out Ricky Shakes' right-foot piledriver on the stroke of half-time.
The Gills keeper denied Cureton a brace a minute from time with another fine piece of goalkeeping.
Aaron Brown picked out Cureton with a right wing cross but Jason Brown came racing out of his goal to palm the striker's close-range shot away.