Andreas Weimann returned to torment Derby as Bristol City won 2-1 at Pride Park.
The Austrian attacker, who left Derby in the summer of 2018, scored the first and was involved in Josh Brownhill's second at the end of the first half.
Derby had plenty of possession but created few clear chances until a superb late strike from Jack Marriott gave them hope, yet City kept their nerve to take the points.
Both teams made two changes, with Derby bringing in record signing Krystian Bielik for his first league start.
The Pole took up a midfield role, but it was Weimann who made the first telling contribution when he opened the scoring in the 16th minute.
A mishit shot from Kasey Palmer seemed to wrong-foot Derby's defence and fell to Weimann, who shaped to shoot before side-stepping Kelle Roos and finding the bottom corner.
Derby's response was instant as Mason Bennett surged forward and had a shot deflected over, before Kieran Dowell's low strike was blocked by a defender.
City's defence looked far from secure and they came close to conceding in the 34th minute when Bennett headed a ball back across goal and it was scrambled behind for a corner.
Derby should have equalised in the 39th minute when Bennett played in Tom Lawrence at the back post, but his low shot was blocked by Daniel Bentley.
City had been on the back foot, but they were gifted a second just before the break when Scott Malone gave the ball away, Weimann dummied Jack Hunt's pass and Brownhill fired in from 12 yards.
Malone was replaced for the second half, which Derby started strongly, with Lawrence sending a 20-yard free kick over, although City's Benik Afobe broke dangerously only to lose his footing as he went to shoot.
City were inviting Derby on, but they were nearly caught out in the 61st minute when Max Lowe got away on the left, but his cross bounced away off a defender.
Dowell shot over from the edge of the box after a driving run from Lawrence and substitute Marriott had a drive charged down, but they were struggling to carve out a clear opening while City were threatening on the counter.
However, a moment of inspiration from Marriott put Derby back in the game in the 85th minute when he turned just inside the area and arrowed a shot into the top-right corner.
When the board showed five minutes of added time, Derby sensed a chance, but City held on for a deserved victory.