Jorge Grant struck a last-minute winner to put Notts County into the third round of the Emirates FA Cup.
Richard Duffy and Jon Stead (pen) twice fired Notts ahead but the visitors levelled the scores on both occasions, Rob Sinclair and Matt Paterson looking to have secured a replay for their side.
However, Grant had the last word, lashing into the roof of the net from a yard out in the final minute to ensure Notts were in the hat for round three.
Manager Kevin Nolan made one change from the team which started last weekend's 2-1 win over Colchester United with Jon Stead recovering from a leg injury to take the place of Shola Ameobi, who missed out with a groin injury.
The Magpies started well, working a free-kick routine into the Oxford City penalty area but Cristian Navarro was on hand to clear the danger before Lewis Alessandra saw his low cross, intended for Stead, cut out.
Shaun Brisley headed off-target from Carl Dickinson's cross before, at the other end, Matt Paterson, who scored City's winner in round one, headed wide at the back post after a corner caused havoc in the Notts ranks.
Another Dickinson cross spelt danger for the visitors before the half-hour mark but Stead was unable to turn the ball home at the near post.
The striker then saw an acrobatic volley turned around wide by visiting goalkeeper Jack Stevens - but Notts would take the lead from the subsequent corner.
Dickinson's cross was headed across the face of goal by Brisley and, with Oxford unable to clear their lines, Duffy bundled the ball home from a couple of yards out for his second goal of the season.
Notts had another opportunity to double their lead five minutes before the break when Dickinson lined up a free-kick 25 yards out. Unfortunately, the full-back couldn't beat the wall and 1-0 was how it stayed going into the interval.
City fired a warning shot shortly after the restart, Navrro volleying the ball over from just inside the penalty area, before Notts came agonisingly close to a second when Stead's deflected effort cannoned off the post after the forward had held off Christian Oxlade-Chamberlain to latch on to Brisley's ball over the top.
And, just as Notts were cursing their misfortune, the visitors fired home an unlikely leveller, Sinclair picking out the bottom corner after composing himself in the Notts area.
The Magpies needed a swift response and got one two minutes later, winning a penalty after Terry Hawkridge was hacked to the ground by Freddie Grant in the area after he looked set to score from Jorge Grant's lay-off.
Stead took responsibility for the spotkick, sending Stevens the wrong way to nudge Notts back ahead in what was turning into an event-filled cup tie.
And Notts had a golden opportunity to compound the visitors' disappointment when Alessandra capitalised on a defensive error to scamper through on goal. A City defender made a heroic challenge just as he was about to shoot.
City reminded Notts of their own threat shortly afterwards, Paterson curling the ball narrowly wide after being set up by Sinclair, before Alessandra landed a header on top of the net from Tootle's cross.
That was to be the former Rochdale man's final action as he made way for Jonathan Forte.
And Notts kept up their pressure, once again coming close to giving themselves breathing space in the contest when Yates' low effort was weakly parried by Stevens. The keeper recovered in time to prevent Stead an easy tap in, but Notts then worked the ball to Hawkridge in space inside the area. His low shot across goal flashed inches wide.
Once again, however, City made Notts pay for not killing the game off as, with a quarter of an hour to play, Paterson swept home Zac McEachran's low cross to spark scenes of jubilation in the away end.
Now the onus was back on Notts, who saw Elliott Hewitt's 20-yard piledriver blocked before Grant's close-range volley following a neat move was pushed away by Stevens.
With a replay looming large, another superb opportunity passed the Magpies by when, after Hewitt had sent Hawkridge to the byline with a superb through ball, the winger's cut-back just evaded Forte in the centre.
Four minutes were added on at the end of the match and Notts, who have made a habit of scoring late winners this season, did so once again.
Forte's flicked header was palmed away by Stevens but Grant, ever the predator, was in the right place at the right time to smash home and break City hearts.