Bottom side Newcastle revived their hopes of escaping relegation from the Premiership as they secured their first away win for almost 14 months.
Ally Hogg's try helped Newcastle into a 19-6 half-time advantage.
But Gloucester hit back and Akapusi Qera scored as they took a 20-19 lead.
However, a Jimmy Gopperth penalty and Mark Wilson try mean Newcastle move within four points of second-from-bottom Wasps, who they meet on the final day, with two games left to play.
It was the Falcons' first win at Gloucester for 14 years.
After Gopperth and Freddie Burns had exchanged first-half penalties, the hosts were forced on to the back foot by Newcastle's greater endeavour.
When Gopperth gave Hogg the chance to go over with a defence-splitting pass, it was no more than the visitors deserved.
In the second half, Burns's fourth successful penalty brought Gloucester to within striking range as the hosts increased the pressure.
When Gloucester moved possession wide the visitors finally ran out of defensive numbers and Qera touched down, with Burns then giving them the lead with his fifth penalty.
But Newcastle hit back and Gopperth edged them back in front with his fifth penalty after Mike Tindall was whistled for shirt-pulling off the ball.
Wilson put Gloucester out of their misery when he stormed clear unopposed from a line-out, with Gopperth's conversion securing victory and giving Newcastle fresh hope of avoiding the drop.
Gloucester: May; Sharples, Tindall, Fuimaono-Sapolu, Simpson-Daniel; Burns, Runciman; Murphy, Lawson, Harden; Hamilton, Brown; Buxton, Qera, Narraway (capt).
Replacements: Dawidiuk, Thomas, Knight, James, Strokosch, Lewis, Taylor, Molenaar.
Newcastle: Goosen; Uys, Helleur, Fitzpatrick, Shortland; Gopperth (capt), Stringer; Golding, Vickers, Murray; Hudson, Swinson; Hogg, Welch, Balding.
Replacements: Thompson, Shiells, Hall, Goode, Tu'ifua, Wilson, Chudley, Catterick