Burnley saved their best until last to sign off from the Premier League Cup in stunning style.
The Clarets were unable to qualify for the last 16 of the competition after just one previous win in Group B.
But in their final game they produced a top-notch performance to beat previously unbeaten group leaders Sunderland in an eight-goal thriller at Stockport County's Edgeley Park.
It took two pitch inspections to get the game on following heavy rain after the fixture was moved from Turf Moor.
And the Clarets were delighted it got the go-ahead as they outgunned a Sunderland side which has competed with some of Europe's top clubs to reach the semi-finals of the Premier League's International Cups.
Jimmy Dunne celebrates putting the Clarets in front
Kevin Long was a pillar of strength at the back for Burnley as he continued his comeback from injury, while Daniel Agyei (above) scored twice - including one magnificent solo effort - after making it as far as the bench in the Premier League at Hull last Saturday.
Jimmy Dunne, Arlen Birch - with something resembling a scorpion kick - and a trialist also hit the target as the Clarets came from behind to give a highly satisying end to a rewarding first stab at the competition.
Sunderland included a handful of players who had been in their match-day squad for the Black Cats' FA Cup third-round replay defeat at Turf Moor in January.
And one of those, forward Josh Major, had the opening chance of a remarkable game with a low shot which was saved by Connor Mitchell.
From the corner that followed, Dunne headed off the line from Dan Casey and with 23 minutes gone Burnley went ahead with a superb goal from Ageyi.
The striker picked up the ball 10 yards inside his own half and launched a dynamnic run which took him past the covering Sunderland defenders and into the penalty area before burying a low, left-footed strike into the bottom corner.
The lead lasted just seven minutes as Sunderland hit back with a quick double to take the advantage as Reece Greenwood slotted home at the second attempt and the quick-footed Joel Asoro, who came off the bench in last month's Cup tie, fed Maja for a smart finish.
Arlen Birch scores with a sensational flick
But Burnley's response was everything coach Michael Jolley would have wanted as his side went back in front before the break.
Thomas fired across the face of goal and then in a pivotal 60 seconds, Long made a superb goalline clearance from Asoro before Burnley went straight up the other end and made it 2-2 when Dwight McNeil crossed for Agyei to head home from close range.
The Clarets then went ahead in first-half stoppage time when Dunne's powerful header from a McNeil corner went in via post and keeper James Talbot.
And it was another McNeil corner which saw Burnley go 4-2 up five minutes after the break as Sunderland were stunned again.
Tristan Juneau was twice denied by blocks in front of goal but when McNeil swung over the resulting corner, Birch cleverly flicked the ball over his shoulder with the heel of his right foot to steer the ball into the back of the net.
There was barely a dull moment and Burnley's fifth goal stuck to the script as a midfield trialist lashed a first-time drive into the top corner from 25 yards.
Sunderland pulled a goal back when Maja made it 5-3 from the penalty spot after he had been tripped by Long but the Clarets had earned their breathing space and Agyei - a constant threat with his pace and power - almost completed his hat-trick in the closing moments with a shot which flew just wide.
Burnley: Mitchell; Birch, Trialist, Long, Wilson; Juneau (Wood 83), Dunne, Trialist (Trialist ht), McNeil; Thomas (Trialist 55), Agyei. Substituites: Aghayere, Olomewewe.
Sunderland: Talbot, Robson, Casey, Brotherton, Hume; Greenwood, Embleton, Robson, Molyneux; Maja (Gamble 84), Asoro. Substitutes: Strjjek, Wright, Poame, Taylor.
Referee: Peter Bankes