Rob Edwards's side could not go down no matter what transpired in the 3pm kickoffs, but three points was a must if they were to guarantee taking the fight for safety to the final day.
The Hatters were on course to do just that thanks to an Albert Sambi Lokonga header, but West Ham - playing their last home game under David Moyes - turned the tide in the second half through James Ward-Prowse, Tomas Soucek and George Earthy.
As a result, Luton remain three points adrift of safety with just three left to fight for, and if Nottingham Forest - whose goal difference is significantly superior - earn at least a draw from their evening clash with Chelsea, the Hatters will be down.
However, there was an air of celebration for West Ham as Moyes enjoyed the perfect London Stadium farewell, one which takes the ninth-placed Irons to within two points of Manchester United and Chelsea, albeit having played two more games.
Sambi Lokonga opener gives Luton hope
Only one change was made to the West Ham side that shipped five to Chelsea at Stamford Bridge, as Ward-Prowse took Edson Alvarez's place, while Luton - who had Chiedozie Ogbene back on the bench - went with an unchanged XI.
Despite it being Moyes's special day at the London Stadium, there was no room for sentiment for the desperate Hatters, who needed just six minutes to capitalise on more atrocious Hammers defending.
After Elijah Adebayo had a shot blocked, the ball came back out to Alfie Doughty on the left, and the full-back's cross found Arsenal loanee Sambi Lokonga, who made an untracked run into the box and powered a header into the bottom corner.
The visitors had only prodded the West Ham bear, though, and the hosts came within inches of drawing themselves level in the 13th minute, but Jarrod Bowen's volley from Lucas Paqueta's cross whacked the post.
Luton were otherwise not resting on their laurels in search of a second, but West Ham were inevitably committing bodies forward wherever possible and were peppering Thomas Kaminski's goal with a succession of shots, albeit unsuccessful ones.
The hosts' efforts to claw their way back into the tie received a huge boost in the 39th minute, as Luton's midfield maestro Ross Barkley came off through injury to be replaced by Jordan Clark, but Edwards's side got to their break with their crucial lead intact, leading to the familiar sound of boos from the West Ham faithful.
Hammers turnaround hands Moyes perfect send-off
Despondency quickly turned to delight from the home crowd, though, as just nine minutes into the second 45, Kaminski could only deflect a Bowen cutback into the path of Ward-Prowse, whose low strike evaded several Luton shirts and found the bottom corner.
The chances soon began to come thick and fast for Moyes's men, more specifically Michail Antonio, who had two headers brilliantly kept out by Kaminski in the 60th and 61st minute, but it was ostensibly only a matter of time before the Irons turned the tide.
True enough, the West Ham comeback was complete in the 65th minute, where Tahith Chong appeals for a foul from Vladimir Coufal fell on deaf ears, and even though Luton managed to half-clear a Ward-Prowse cross, Soucek met the defensive header with an exquisite volley into the bottom corner from 20 yards.
Luton were highly fortunate to still be in the contest in the 70th minute, as Mohammed Kudus inexplicably fired wide from a Bowen delivery, but the Ghana international atoned for that mishap with 14 minutes of normal time remaining.
Coufal's own lung-busting run from inside his own half preceded the Czech right-back laying off Kudus, who skilfully jinked his way to the byline and cut back for 19-year-old Earthy to tap in his first senior Hammers goal.
Moyes now faces the trickiest end to his West Ham reign possible, heading to Manchester City on the final day of the season on May 19, while Luton - who will watch Nottingham Forest's clash with Chelsea this evening with bated breath - may still be clinging onto the thinnest of survival hopes by the time they host Fulham in eight days' time.