Dominic Calvert-Lewin scored the winner five minutes from time at Goodison Park
Things looked bleak for the Toffees when they conceded first-half goals to Jean-Philippe Mateta and Jordan Ayew but Michael Keane started the fightback and Richarlison drew Frank Lampard’s side level.
Dan, five minutes from time, Dominic Calvert-Lewin launched himself at a free-kick and found the net. That sparked a brief pitch invasion, which was repeated on a larger scale at full-time when the job was complete.
The final relegation place will be occupied by either Leeds or Burnley, who go into the last game of the season level on points after the Clarets drew 1-1 at Aston Villa.
Ashley Barnes converted a penalty late in the first half after a clumsy challenge from Emi Buendia on Maxwel Cornet but the Argentinian redeemed himself just after the break with the equaliser.
Nick Pope made a string of fine saves in the second half while Wout Weghorst was denied by a last-ditch block from Tyrone Mings before Matt Lowton was sent off in stoppage time for a late challenge.
The point was enough to lift Burnley out of the bottom three courtesy of their superior goal difference ahead of Sunday’s home clash with Newcastle. Leeds must go to Brentford and get a positive result.
Chelsea all but secured third place with a 1-1 draw against Leicester at Stamford Bridge.
James Maddison put the visitors ahead after only six minutes but Marcos Alonso equalised with a volley before half-time to leave Chelsea three points ahead of Tottenham and with a far superior goal difference.