A Sam Long-inspired Oxford came from two goals down late in the second half to beat Gillingham 3-2 and move into the top six in Sky Bet League One for the first time this season.
Vadaine Oliver and Robbie Cundy put the Gills two up after 72 minutes.
But substitute Sam Winnall and right-back Long turned the match on its head.
Portsmouth's defeat at MK Dons had opened the door for Karl Robinson's team, who had scored 10 goals in their previous two games.
Oliver fired the visitors ahead five minutes before the break with a low shot on the turn when the home side failed to clear Ryan Jackson's long throw.
Steve Evans' men doubled their lead with Cundy turning in Jordan Graham's cross from five yards.
Winnall replied with a low long-range effort a minute later.
Long levelled by heading Josh Ruffels' deep cross into the top corner in the 84th minute and then popped up in the box again to stab home Cameron Brannagan's cross in stoppage time for a late winner.