Accrington Stanley 3 Mansfield Town 2
The 19-year-old wideman cut inside from the left and unleashed an unstoppable 83rd minute winner as Stanley secured only their second win in 14 games.
Captain Paul Mullin handed the home side a dream start when he opened the scoring after just 25 seconds, but the Stags hit back through first-half goals from Barry Conlon and Stephen Dawson.
But Michael Welch equalised with a 30-yard piledriver on the hour mark before Whalley's superb individual effort with seven remaining wrapped up the points for John Coleman's side.
Stanley had not won at the Fraser Eagle Stadium since beating Wycombe Wanderers on September 30.
But Mullin capitalised on the terrible defensive mix up between Alex Baptiste and goalkeeper Jason White to tap home his tenth goal of the season and give the hosts the lead.
Accrington were unfortunate not to double their advantage on 25 minutes when the outstanding Whalley's 25-yard free-kick struck the base of the post.
However, the visitors were level seven minutes later when keeper Rob Elliot failed to deal with Matt Hamshaw's free-kick and Conlon fired home his second goal in two games since joining from Darlington.
Hamshaw was once again heavily involved in Town's second goal on the stroke of half-time when he threaded an exquisite pass through to Dawson who swept emphatically home.
Hamshaw went close after the break from another set piece before Welch levelled matters with a thunderous 30-yard free-kick.
Elliot nearly gifted Mansfield the three points when his poor clearance went straight to Michael Boulding but the substitute shot straight at the keeper when clean through on goal.
Less than 30 seconds later it was Whalley who went close again but his shot flew inches past the upright.
Chances continued to flow at each end and Conlon lobbed just wide on 82 minutes and that proved decisive when Whalley collected the ball 35 yards out, surged at the Mansfield defence and curled a magnificent winner past a stranded White.