Tony Palladino took his 11th five-wicket haul for Derbyshire, and reached the milestone of 350 first-class wickets, but Gloucestershire took the lead on Day Two at The 3aaa County Ground.
Gloucestershire started the day on 27-1 and Derbyshire took three wickets in the morning session to reduce the visitors to 135-4, but they responded with Chris Dent (94) and Phil Mustard, on-loan from Durham, who scored his first century for Gloucestershire to secure a first innings lead of 89.
Tom Milnes (2-57) and Callum Parkinson (2-56) struck at regular intervals, whilst Palladino (5-74) took four of the last five wickets, including the 350th of his career, to leave Gloucestershire 331 all out, with Mustard unbeaten on 107.
The hosts had seven overs to bat before the close, but lost both their openers to finish on 16-2, trailing by 73 runs.
Derbyshire would have been the side looking to take control when Milnes struck in the second over of the morning before Gloucestershire had added to the overnight total.
But George Hankins showed good judgement and sound temperament to stay with Dent for 15 overs until he was bowled by Callum Parkinson (2-56) for 34. Hamish Marshall followed shortly after, lbw to Palladino, with the visitors 135-4 at lunch.
Billy Godleman switched his bowlers around but Dent and Mustard showed patience and selectivity to add 85 for the fifth wicket before Dent fell for 94 to Parkinson, caught at mid-on.
Mustard and Jack Taylor tilted the advantage towards the visitors with a stand of 74 before the second new ball gave the game another twist. Taylor (36) chipped to mid-wicket to give Palladino his milestone and the seamer found just enough away movement to bowl Craig Miles (5) before David Payne (1) edged a drive into his stumps.
When Liam Norwell chased a wide one from Will Davis, Mustard was in danger of being stranded but he pulled Davis for his 13th four to reach an excellent hundred.
Josh Shaw helped add a precious 31 runs before he became Palladino’s fifth victim, leaving Derbyshire seven overs to negotiate and they lost Ben Slater (6) lbw to Payne in the first before Billy Godleman (5) edged Norwell to Mustard in the penultimate over.