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."
Live Text Commentary
Full Time The referee signals the end of the game.90:00 +5:30
Jo Kuffour takes a shot. Save made by Ryan Clarke.90:00 +4:18
Free kick taken by Ross Flitney.90:00 +4:18 Booking
Booking Michael Duberry is cautioned.90:00 +4:09
Michael Duberry concedes a free kick for a foul on Matt Lawrence.90:00 +3:10
Ross Flitney restarts play with the free kick.90:00 +3:10 Booking
Booking Asa Hall goes into the book.90:00 +3:00
Unfair challenge on Curtis Weston by Asa Hall results in a free kick.90:00 +2:30
Charlie Lee gives away a free kick for an unfair challenge on Asa Hall. Direct free kick taken by Liam Davis.90:00 +2:01
Peter Leven takes a shot. Charlie Lee gets a block in.90:00 +0:50
Effort on goal by James Constable from just outside the penalty area goes harmlessly over the target.90:00 +0:12
Free kick awarded for an unfair challenge on Matt Lawrence by Alfie Potter. Ross Flitney restarts play with the free kick.89:50
Jo Kuffour is ruled offside. Damian Batt takes the direct free kick.88:40
James Constable is flagged offside by the assistant referee. Ross Flitney restarts play with the free kick.88:10
Alfie Potter takes a shot. Save by Ross Flitney.87:14
Jake Wright takes the direct free kick.87:14 Dismissal
Dismissal Lewis Montrose is shown a red card for serious foul play.86:57
Lewis Montrose challenges Asa Hall unfairly and gives away a free kick.85:56
Foul by Liam Davis on Curtis Weston, free kick awarded. Ross Flitney restarts play with the free kick.84:49
Matt Lawrence fouled by Liam Davis, the ref awards a free kick. Garry Richards restarts play with the free kick.
The offside flag is raised against Jo Kuffour. Ryan Clarke restarts play with the free kick.81:28
Direct effort from the free kick comes in from Charlie Lee, save by Ryan Clarke.81:28 Booking
Booking Jake Wright is shown a yellow card for unsporting behaviour.81:20
Free kick awarded for an unfair challenge on Lewis Montrose by Jake Wright.80:47
Short corner taken by Danny Philliskirk from the right by-line.78:16
Matt Lawrence restarts play with the free kick.78:16 Booking
Booking The referee cautions Alfie Potter for unsporting behaviour.78:10
Unfair challenge on Charlie Lee by Alfie Potter results in a free kick.77:43 Substitution
Substitution (Oxford Utd) makes a substitution, with Asa Hall coming on for Paul McLaren.75:48
Alfie Potter fouled by Charlie Lee, the ref awards a free kick. Robert Hall takes the direct free kick. Peter Leven takes a shot. Save made by Ross Flitney.73:01 Substitution
Substitution Luke Rooney goes off and Andy Frampton comes on.70:06
Garry Richards takes the direct free kick.70:06 Booking
Booking Danny Philliskirk receives a yellow card.69:52
Unfair challenge on Matt Fish by Danny Philliskirk results in a free kick.67:54
Liam Davis produces a left-footed shot from just outside the box that misses to the right of the target.67:24
Inswinging corner taken from the right by-line by Peter Leven.67:24 Substitution
Substitution Danny Philliskirk replaces Deane Smalley.67:05
Alfie Potter takes a shot. Matt Lawrence gets a block in.65:01
Free kick awarded for an unfair challenge on Robert Hall by Matt Fish. Peter Leven restarts play with the free kick.64:28 Substitution
Substitution Charlie Lee replaces Chris Whelpdale.63:13
Inswinging corner taken left-footed by Peter Leven played to the near post, save by Ross Flitney.62:04
Outswinging corner taken by Peter Leven from the left by-line, save made by Ross Flitney.61:44
Robert Hall takes a shot. Save by Ross Flitney.61:30
Matt Fish gives away a free kick for an unfair challenge on Robert Hall. Peter Leven takes the direct free kick.60:19
Jake Wright concedes a free kick for a foul on Jo Kuffour. Matt Fish takes the direct free kick.59:23
Luke Rooney takes a shot. Ryan Clarke makes a save.55:01
James Constable concedes a free kick for a foul on Garry Richards. Direct free kick taken by Ross Flitney.54:55 Substitution
Substitution Simon Heslop leaves the field to be replaced by James Constable.52:38
Outswinging corner taken from the left by-line by Peter Leven, Matt Fish makes a clearance.52:18
Corner taken short by Peter Leven.51:56
Simon Heslop takes a shot. Save made by Ross Flitney.51:11 Substitution
Substitution Danny Jackman is brought on as a substitute for Frank Nouble.49:10
Damian Batt has an effort at goal from long range that misses to the right of the target.48:08
Direct free kick taken by Peter Leven.48:08 Dismissal
Dismissal Joe Martin receives a red card.47:52
Robert Hall fouled by Joe Martin, the ref awards a free kick.46:19
Alfie Potter is caught offside. Ross Flitney takes the direct free kick.45:18
Lewis Montrose concedes a free kick for a foul on Deane Smalley. Direct strike on goal from the free kick comes in from Peter Leven, save by Ross Flitney.45:01
The referee gets the second half underway.45:00 +2:10 Half time
Half Time The players leave the pitch at half time.44:16 Goal scored
Goal! - Lewis Montrose - Gillingham 1 - 0 Oxford Lewis Montrose finds the back of the net with a goal from a long way out to the top left corner of the goal. Gillingham 1-0 Oxford Utd.38:12
Robert Hall takes a shot. Save by Ross Flitney.37:35
Corner taken by Peter Leven from the left by-line, clearance made by Joe Martin.37:11
Joe Martin concedes a free kick for a foul on Alfie Potter. Michael Duberry takes the direct free kick.36:07
Free kick awarded for a foul by Lewis Montrose on Alfie Potter. Peter Leven restarts play with the free kick.33:45
Liam Davis takes a shot. Save by Ross Flitney.32:51
Foul by Lewis Montrose on Paul McLaren, free kick awarded. Jake Wright restarts play with the free kick.32:13
Alfie Potter produces a left-footed shot from deep inside the area which goes wide of the left-hand post.28:02
Foul by Deane Smalley on Luke Rooney, free kick awarded. Free kick crossed right-footed by Luke Rooney.27:46
Luke Rooney takes a short corner.27:10
Free kick awarded for a foul by Damian Batt on Luke Rooney. Luke Rooney takes the direct free kick.26:30
Free kick awarded for an unfair challenge on Matt Fish by Deane Smalley. Ross Flitney restarts play with the free kick.25:52
Luke Rooney challenges Damian Batt unfairly and gives away a free kick. Direct free kick taken by Ryan Clarke.24:37
Matt Fish takes the direct free kick.24:37 Booking
Booking Caution for Paul McLaren.24:20
Paul McLaren challenges Jo Kuffour unfairly and gives away a free kick.22:41
Robert Hall takes a shot. Save made by Ross Flitney.21:35
Corner taken by Peter Leven from the left by-line, Headed effort from inside the area by Michael Duberry misses to the left of the goal.18:18
Paul McLaren delivers the ball, Alfie Potter takes a shot. Clearance by Curtis Weston.18:18 Booking
Booking Booking for Joe Martin for unsporting behaviour.18:04
Joe Martin gives away a free kick for an unfair challenge on Damian Batt.15:23
Chris Whelpdale takes a shot. Save by Ryan Clarke.13:02
Luke Rooney takes a shot. Save by Ryan Clarke.9:47
Luke Rooney takes a shot. Paul McLaren gets a block in.8:35
Long range shot from Simon Heslop misses to the left of the target.7:00
Alfie Potter has an effort at goal from deep inside the area missing to the left of the target.6:24
Inswinging corner taken right-footed by Luke Rooney played to the near post, Deane Smalley makes a clearance.5:17
Lewis Montrose concedes a free kick for a foul on Alfie Potter. Paul McLaren takes the direct free kick.3:28
Curtis Weston gives away a free kick for an unfair challenge on Robert Hall. Free kick taken by Peter Leven.2:54
Inswinging corner taken from the left by-line by Luke Rooney, clearance by Jake Wright.1:27
Free kick awarded for an unfair challenge on Damian Batt by Luke Rooney. Damian Batt takes the direct free kick.0:00
The referee starts the match.
Live data and text provided by our data suppliers