Bobby Reid netted his seventh goal of the season as Bristol City romped to a thrilling 4-1 Sky Bet Championship victory over Derby at Ashton Gate.
The visitors went ahead from the penalty spot on 27 minutes as Matej Vydra thundered the ball home off the underside of the crossbar after being brought down by City goalkeeper Frank Fielding.
But the hosts levelled five minutes after the break when Cauley Woodrow netted with a downward header from Joe Bryan's left-wing cross.
Reid made it 2-1 with the second penalty of the match in the 55th minute, sending Scott Carson the wrong way after Jonathan Leko had been tripped by Richard Keogh.
Jamie Paterson put the result beyond doubt with an 83rd-minute free-kick from 20 yards that bounced down off the crossbar, goal-line technology proving the ball had crossed the line before being cleared.
Substitute Famara Diedhiou set the seal on an exhilarating display by Lee Johnson's men in stoppage time, shooting home from a brilliant long ball by Paterson.
Both sides looked committed to attack from the outset and an entertaining first half was packed with incisive moves.
Reid just failed to clear advancing goalkeeper Carson with a header after Keogh's poor back-pass had put Derby in trouble.
A Vydra free-kick from 20 yards on 12 minutes clipped the outside of a post after City centre-back Nathan Baker had clipped Tom Lawrence.
Carson was the first-half hero for Derby, making the first of several saves in the 21st minute to keep out a Woodrow shot.
Fielding escaped without even a yellow card for the foul on Vydra that brought the penalty, presumably because referee Martin Atkinson deemed that the striker was heading away from goal.
The home side upped their game after going behind and Leko should have marked his first start with a goal in the 32nd minute.
The loanee attacker from West Brom moved unmarked onto a Woodrow cross, but his shot was at a good height for Carson, who beat it away.
There was a better save from the Derby goalkeeper 10 minutes later as he went full-length to palm away a glancing header from Paterson.
Reid had the ball in the net for City just before the break, but referee Atkinson had already whistled for a foul on Paterson just outside the box.
The hosts began the second half well as Marlon Pack fired narrowly wide from 30 yards and Woodrow's equaliser was no more than they deserved.
Derby claimed a foul by Bryan before he delivered the cross, but had no complaints about City's penalty that followed.
After both sides had made double substitutions, the all-action contest continued with Bradley Johnson heading inches wide for Derby and Lawrence seeing a deflected free-kick held by Fielding.