Gloucestershire skipper Alex Gidman dragged his side to a four-wicket victory over Surrey at the Oval with 76 not out.
Set a target of 160, the visitors were in trouble when seam duo Yasir Arafat (3-49) and Tim Linley (3-58) combined to reduce them to 54-5.
Gidman, however, counter-attacked during a sixth-wicket stand of 67 with Richard Coughtrie.
Coughtrie (10) was bowled by Linley with 39 still required but Ed Young (21no) joined Gidman, who struck 13 fours during his 111-ball contribution, to finish the job.
Earlier on day three, Surrey had advanced their second innings from 145-5 to 195 all out.
Mark Ramprakash, on 61 overnight, fell lbw to Jon Lewis for 75, while Ian Saxelby claimed three of the wickets to fall - including two in an over - to complete career-best figures of 6-69.
Seam bowler Saxelby, 22, also earned his maiden 10-wicket match haul, having also bagged 4-73 in the first innings.
Mark Ramprakash stood firm to maintain Surrey's hopes in their LV= Championship Second Division match with Gloucestershire at The Oval.
The former England batsman made a cultured half-century - the 147th of his first-class career - to guide the hosts into a 110-run lead at stumps on day two.
However, with Surrey already five down having reached 145-5, it is Gloucestershire who will be confident of pushing on for victory.
The visitors resumed in the morning on 171-4 in pursuit of Surrey's first innings total of 226, but ending up limping to just a narrow 35-run advantage after losing their final six wickets for just 60 runs.
Tim Linley the pick of the Surrey attack with three for 66 and it was he that dismissed both Alex Gidman (43) and David Payne (23) who failed to build on early let-offs.
Surrey's second innings got off to a poor start when Jason Roy departed for just two after playing around an Ian Saxelby delivery.
Skipper Rory Hamilton-Brown followed for a quickfire 26 to the same bowler while Zander de Bruyn (13), Steven Davies (14) and Tom Maynard (nought) were also dismissed cheaply.
But Ramprakash held the fort and will look to help Surrey post a challenging target on day three.
Fourteen wickets fell as Gloucestershire enjoyed the better of the opening day against Surrey at the Oval.
The visitors closed on 171-4 in reply to Surrey's 225 all out and will be looking to build a first-innings lead on Monday.
But for Zander de Bruyn's responsible 66 from 90 deliveries Surrey might already be ruing preparing a green, seamer-friendly pitch.
The South African found useful lower order allies in Yasir Arafat and Jade Dernbach as the hosts edged to one bonus batting point under leaden skies.
When the clouds dispersed in late afternoon the Gloucestershire batsmen, led by Chris Taylor (52), were rewarded for demonstrating far greater resolve.
Gloucestershire quickly shrugged off the early loss of Chris Dent, caught behind off Linley in the third over.
It needed a superb delivery from Dernbach to see the back of Kane Williamson.
Hamish Marshall, who was dropped on 19 and 33, and Chris Taylor, also fell victim to balls that appeared to keep low.
Taylor, however, led from the front with a responsible 52 off 70 balls, and Alex Gidman batted equally sensibly.