Gillingham ended up with nine men but held on to end Oxford United's eight-game unbeaten run.
The U's dominated but Lewis Montrose scored from 25 yards out on the stroke of half-time after Ryan Clarke saved Jo Kuffour's effort.
Joe Martin was sent off for a second booking early in the second half and Montrose was shown a late red for fouling U's substitute Asa Hall.
Alfie Potter and James Constable missed late chances to level for the visitors.
Potter shot straight at Ross Flitney and Constable's injury-time chip went wide.
The results lifts Gillingham up into fifth and above Oxford, who drop to seventh in the table.
VIEWS FROM THE DRESSING ROOM
Gillingham manager Andy Hessenthaler told BBC Radio Kent:
"I'm very proud of my players. Going down to 10 men was always going to be difficult but today hopefully showed our fans what the team is all about.
"I ask the players to wear the shirt with pride and give everything they can for the football club and I thought we were outstanding.
"I thought Lewis Montrose was outstanding second half, unfortunately he's got sent off, rash challenge, young boy.
"I'm not going to be harsh on the lad because he's a fantastic player and he's won the game for us."
Oxford United boss Chris Wilder told BBC Oxford:
"Results are decided in the final third and yet again we've missed some fantastic chances.
"We just needed to be a bit more patient. We tried to force it a bit in the second half.
"It's a little like a broken record but I know we're on the right tracks. We're a decent side."
Gillingham 01 Flitney 06 Richards 12 Martin Dismissed after an earlier booking 15 Lawrence 16 Fish 07 Whelpdale (Lee - 65' ) 10 Weston 14 Rooney (Frampton - 74' ) 19 Montrose Dismissed 29 Nouble (Jackman - 52' ) 33 Kuffour Substitutes 28 Gazzaniga 03 Frampton 18 Jackman 04 Lee 23 Payne Oxford United 01 Clarke 02 Batt 05 Duberry Booked 06 Wright Booked 04 McLaren Booked (Hall - 78' Booked ) 08 Heslop (Constable - 55' ) 20 Leven 26 Davis 10 Smalley (Philliskirk - 68' Booked ) 15 Potter Booked 30 Hall Substitutes 16 Whing 27 Kinniburgh 14 Hall 33 Philliskirk 09 Constable