Jeff Goulding came off the bench to secure a last-gasp win over Oxford and keep Aldershot's survival hopes alive.
The Shots had been in control through Paul McCallum's early strike and Craig Reid's penalty just after half-time.
But a Scott Davis free-kick reduced the arrears and Jon-Paul Pitmann levelled things five minutes from time despite a red card for Michael Raynes.
However, substitute Goulding headed in Danny Rose's free-kick two minutes later to secure a first win in seven.
The Hampshire side are now two points from safety and have a game in hand on six of the seven sides directly above them.
VIEW FROM THE DRESSING ROOM
Aldershot Town manager Andy Scott told BBC Surrey:
"We made it hard for ourselves but the way we responded was tremendous.
"I think we deserved to win the game and it's the first time we've scored three times since I've been here.
"The set-piece from Adam Mekki was a fantastic delivery and Jeff (Goulding) has got on the end of it and we deserved to win the game and it keeps us in the hunt.
"The crowd played a big part today because going 2-0 up and then 2-2, there could have been nerves and they responded and we had to for them."