LIVERPOOL, England (AP) — Everton secured its Premier League survival by recovering from two goals down to beat Crystal Palace 3-2 in the penultimate match of the season on Thursday.

It looked like Everton’s fate would go down to the wire on Sunday after Jean-Philippe Mateta and Jordan Ayew scored in the first half for the south London club.

But Michael Keane started the comeback in the 54th, Richarlison leveled in the 75th and Dominic Calvert-Lewin headed Everton in front in the 85th to spark an invasion of the field by the home fans.

Also read | Fan violence at Nottingham Forest: Symptom or a disease?

The game resumed and Everton ensured its stay in the top division will extend to 69 years.

The Everton fans made their presence felt outside Goodison Park with blue smoke shrouding the streets as the teams arrived.

There wasn’t anything to celebrate inside after the 21st minute when Mateta got in front of defender Vitalii Mykolenko to head in from Eberechi Eze’s free kick.

Palace doubled its lead in farcical fashion in the 36th minute. Mateta robbed Seamus Coleman of possession in midfield and ran toward goal. Goalkeeper Jordan Pickford punched his cross clear and parried Wilfried Zaha’s follow-up, but Everton midfielder Abdoulaye Doucouré failed to clear the danger and Ayew poked home.

Also read | Frankfurt beat Rangers 5-4 in penalties to win Europa title after 42 years

Everton changed formation at the break as Dele Alli replaced Andre Gomes, and it paid off as Keane got the hosts back in the game by firing home after Mason Holgate headed a free kick back into the danger zone.

The equalizer came after Demarai Gray drove forward down the right and crossed deep for Alli, who headed the ball back in. Although Richarlison mis-controlled at first, he did enough to get a shot away and find the bottom corner of goalkeeper Jack Butland’s goal.

Calvert-Lewin scored when he got in behind Marc Guehi to meet Gray’s free kick from the right.