Derbyshire 352 (Madsen 95, Slater 70, Freckingham 4-91) and 331-8 (Hughes 101, Madsen 66, Slater 56, Godleman 51,) drew with Leicestershire 329 (Chappell 96, Eckersley 50, Footitt 7-71) and 363 (Cosgrove 156, Ali 62)
Derbyshire fell just short of what would have been a famous victory in a thrilling end to the Division Two county championship match against Leicestershire at Derby.
Set 341 in 81 overs, 101 from Chesney Hughes plus half centuries from Billy Godleman, Ben Slater and skipper Wayne Madsen looked to have secured Derbyshire's first home championship win of the season.
But Wes Durston's dismissal with 14 needed sparked a collapse that saw four wickets fall for two runs and with 10 needed off the last five balls, Derbyshire settled for a draw at 331 for 8.
Leicestershire needed to set a challenging target with key bowlers missing and Cosgrove added another 30 runs to his overnight score before he was last out.
He drove Durston for two sixes, the second taking him past 150, but when he went for a third, he was stumped to give Durston his second six wicket haul in a month.
Derbyshire began their chase knowing the pitch was still a good one to bat on but they needed a solid start and Godleman and Slater provided it with an opening stand of 103 in 27 overs.
Ben Raine was hit for six fours in 14 balls but he made the first breakthrough when Godleman misread the length and was lbw and Slater followed before tea, leg before trying to work Zak Chappell through mid-wicket.
At the interval, Derbyshire needed to accelerate with another 186 required from 34 overs and Hughes opened up by pulling Rob Taylor for six and driving the next ball for four.
Madsen swept Dan Redfern for four to pass 1,000 first-class runs for the season and Derbyshire went into the last hour needing 94 from 16 overs with Leicestershire increasingly desperate for a wicket.
Cosgrove turned to the off-spin of Aadil Ali but Madsen reverse swept him for three to reach 50 and complete 1,000 championship runs before he drove Redfern for another boundary.
Derbyshire went into the last 10 overs needing 64 and Hughes reduced that by two to reach his second hundred of the season from 152 balls but was then yorked by Taylor who had Madsen caught behind in his next over.
Durston responded by driving Raine for a much needed boundary to bring the target down to 35 from 30 balls and 16 came from Taylor's next over as Durston pulled him for four and six off consecutive balls.
That looked to have settled it but Durston drove to long on, Tom Poynton was bowled by Raine and Tom Millns was run out going for a second off an overthrow to leave 11 off the last over.
When Tom Taylor was run out going for a second off the first ball, Tom Knight blocked the next five balls from Ollie Freckingham to leave Madsen to reflect on what might have been.
"We are disappointed not to get the win but there are lots of positives to take because I thought we played brilliantly to get ourselves into that position. To chase down that sort of a score on the last day is no mean feat and we were in the position we wanted to be but unfortunately we threw it away at the end.
"We were under a run a ball so we should have got across the line but then at the end we felt it was too much a task in the last over so we had to close up shop."
Leicestershire head coach Andrew McDonald said: "It was a classic four day game, there was no winner but it went down to the wire and I'm really impressed with the way the boys fought . We stuck at it and to have an opportunity to almost win it at the end I think speaks volumes for where this group of players is at.
"I don't want to get too carried away with a draw but if people were here to see that they would understand why it was a significant effort and a significant step forward."