Brett Pitman came off the substitute's bench to score the winner for Bournemouth deep into injury time.
Having fought back from 2-0 down, Luton were 3-2 ahead with two minutes to go and seemingly about to inflict on bottom place Bournemouth their 17th league defeat of the season.
But then 18-year-old Sam Vokes equalised and set up an astonishing climax in which Pitman headed home a centre from Lee Bradbury with two minutes of extra-time remaining.
Bournemouth's win was only their sixth of the season in a week when they looked like joining Luton in administration.
Max Gradel put Bournemouth ahead in the second minute when he volleyed in a right-wing centre from Bradbury.
Jo Kuffour seized on another pass from Bradbury in the 31st minute to race clear and beat goalkeeper Dean Brill with a low shot.
Injury-plagued Bournemouth gave 18-year-old keeper Ryan Pryce his debut and he denied Drew Talbot with a superb block soon after Kuffour's goal.
Luton were thrown a lifeline a minute before half-time when their former defender Russ Perrett fouled Paul Furlong and Matthew Spring converted the penalty.
Luton equalised in the 60th minute when Dean Morgan was left unmarked to beat Pryce easily from ten yards.
Kuffour had a shot blocked on the line by Brill before Luton went ahead in the 78th minute with a goal which looked like sealing their revival.
Talbot took advantage of a mistake by Perrett to set up a header for Spring which was brilliantly saved by Pryce only for the rebound to be hammered in by Furlong.
Luton looked destined to collect three useful points until the 89th minute when Vokes turned on a centre from the ever dangerous Gradel and then set up Pitman for the winner.