England centre Billy Twelvetrees kicked a controversial late penalty to give Gloucester their first Aviva Premiership victory of the season and leave Northampton crestfallen.
Saints looked to have done enough to move top of the league when wing Jamie Elliott struck a minute from time following stunning approach work by juggernaut Wales wing George North, with fly-half Stephen Myler's conversion edging them ahead.
But Northampton were mysteriously penalised at a scrum deep into injury time, and Twelvetrees struck from 35 metres for a 26-24 verdict.
Twelvetrees and his fellow England back Charlie Sharples both scored tries for the home side, but it was a second-half touchdown from Gloucester academy player Elliott Stooke that appeared to have initially edged Gloucester home.
England Under-20 lock Stooke pounced after 66 minutes, while fly-half Freddie Burns chipped in with two penalties and a conversion to put Gloucester six points in front.
Northampton took an early lead through full-back Ben Foden's try, and there was a second-half score for lock Samu Manoa, with Myler adding seven points from the boot - but Gloucester closed out the game.
After conceding 66 points in losing to Sale and Saracens - and seeing their England Saxons prop Nick Wood hit with an eight-week ban following his red card for stamping at Allianz Park - Gloucester showed tremendous character.
Northampton needed barely five minutes to open their account as they breached Gloucester's defence with ease through centre Luther Burrell's powerful surge, which created sufficient space out wide and allowed Foden an angled run-in.
Myler converted, but Gloucester bounced back through a spell of territorial dominance that resulted in Burns opening their account through a 14th-minute penalty.
It should have been even better for the home side just five minutes later when Burns placed a clever kick behind Northampton's defence, yet centre Henry Trinder knocked on as he attempted to gather possession and dive over Saints' line.
Gloucester, though, had momentum that was enhanced when Northampton were reduced to 14 men after number eight Sam Dickinson was sin-binned by referee Martin Fox for tackling Gloucester wing James Simpson-Daniel in the air.
A bloodied Simpson-Daniel briefly left the field for treatment, but the home side kept plugging away before wasting a golden opportunity when number eight Sione Kalmafoni's pass drifted behind Gloucester's attacking wave.
And Saints made their opponents pay just before the break as Myler kicked a penalty after Twelvetrees infringed, giving Northampton a 10-3 advantage.
But Gloucester's response was immediate, with its origins in some brilliant link-work between Burns and Twelvetrees that resulted in Sharples crossing wide out.
Burns missed the touchline conversion attempt, yet Gloucester were firmly back in contention, just two points adrift at half-time.
And they underlined resurgence just three minutes after the restart, scoring their second try following sharp work from their former New Zealand Test scrum-half Jimmy Cowan.
Gloucester gained a penalty from a scrum within goalkicking range, but Cowan ignored the safe option, made an incisive break and Twelvetrees finished stylishly by ghosting outside Burrell.
Burns booted the conversion, but the lead lasted barely two minutes as the Saints drove a lineout to within touching distance of Gloucester's line and Manoa touched down before Myler added the extras.
Back came Gloucester, though, as Burns kicked a penalty to leave Northampton one point behind and set up a tense final quarter.
Gloucester boss Nigel Davies and his opposite number Jim Mallinder both began ringing the changes in pursuit of a potentially match-clinching score, and it was Saints that cracked first.
Twelvetrees made initial headway by stretching Saints' defence before a moment of magic from Simpson-Daniel, who weaved his way past two tackles before delivering a one-handed scoring pass to Stooke.
But Northampton then went back in front when Elliott struck after he collected flanker Calum Clark's pass, coupled with a successful Myler conversion, before Twelvetrees felled Saints.