Dominic Calvert-Lewin’s diving header five minutes from time extended Everton’s proud stay in the top flight to 69 years with a 3-2 victory over Crystal Palace on a night for the ages at Goodison Park.

Needing a victory to make themselves safe and avoid an awkward last-day trip to top-four-chasing Arsenal, the situation looked bleak when they went 2-0 down inside 36 minutes.

But manager Frank Lampard’s tactical changes, plus the sheer emotion and force of a raucous crowd, dramatically turned things around in the second half as first Michael Keane and then Richarlison, with his sixth in nine games, teed up a rousing finale.

Jordan Pickford celebrates with fans
Fans celebrated on the pitch at full-time (Peter Byrne/PA)

And with the stage set, Calvert-Lewin – fresh from scoring his first goal since August in Saturday’s defeat to Brentford – launched himself at a free-kick and watched as the Gwladys Street End behind the goal exploded, followed by the rest of the ground.

The pressure had been so unbearable for so long, hundreds of fans and smoke grenades spilled onto the pitch in celebration and, while it was short-lived and good-natured, referee Anthony Taylor and his assistants retreated behind a wall of police on the touchline.

There was another incursion by thousands at the final whistle and inevitably there will be consequences for Everton, but nothing as damaging as what was staring them in the face with 150 minutes remaining of their season.

The calamitous nature of their defending which allowed Jean-Philippe Mateta and Jordan Ayew to put the visitors into a deserved two-goal lead was forgotten on a night of celebration and relief at the final whistle as Lampard’s name was chanted by all four sides of this old ground.

There were echoes of 1994, when Everton came back from 2-0 down to win by the same scoreline and secure safety on the final day after beating a team who played at Selhurst Park, although then it was Wimbledon who were the victims.

The outpouring of joy at the end was like nothing ever seen at Goodison, with the grass covered in blue-shirted fans carrying more smoke grenades and singing their hearts out to the assembled squad of players who, behind a cordon of police and stewards, remained pitchside to witness the scenes.

Those same fans had stretched the length of Goodison Road before kick-off as Everton’s team bus changed its usual route to the ground to accommodate the groundswell of support, which has been growing over the last few weeks, and the players departed the coach in a blue smog.

The smell generated by the haze wafted all the way over to Stanley Park long before the players arrived and many supporters at the heart of the welcome departed the throng literally blue in the face from an atmosphere thick with coloured smoke.

Everton’s 4-0 FA Cup quarter-final defeat at Palace two months ago left a frustrated Lampard questioning whether his players had the “b******s” for a fight.

Since then they have taken 14 points from 10 matches, just enough to get them over the line with a match to spare, but nowhere was it more needed than in their final home game.

Jean-Philippe Mateta scores for Crystal Palace
Everton fell behind to goals from Jean-Philippe Mateta (pictured) and Jordan Ayew (Peter Byrne/PA)

Prior to the traditional rendition of Z-Cars the theme tune to Rocky was blasted out and there were less than two minutes gone when things got physical, with Wilfried Zaha giving Anthony Gordon a shove which provoked a minor skirmish and raised the noise levels further.

Gordon appeared to be a specific target for the visitors, with both Will Hughes and, more controversially Ayew, clattering into the back of him to earn yellow cards.

By then, however, Everton were already behind as after Richarlison’s free-kick clipped the top of the crossbar, possibly helped on by the fingertips of Jack Butland, the hosts’ defensive weaknesses were exposed.

Eberechi Eze’s inswinging free-kick sailed over the heads of a crowded penalty area and Mateta’s downward header beat the dive of Pickford.

When Ayew’s scissor tackle on Gordon right in front of the hosts’ technical area only resulted in a yellow card, another melee ensued. But if Everton were outraged by that, their disgust was off the scale two minutes later.

Dominic Calvert-Lewin scoreS Everton's winner
Dominic Calvert-Lewin scored Everton’s winner (Jon Super/AP)

Seamus Coleman was robbed in the centre-circle by Mateta, whose cross was punched by Pickford only as far as Zaha and, with the goalkeeper only able to half-save the follow-up, Andre Gomes and then Abdoulaye Doucoure – on the goalline – failed to clear as Ayew’s unconvincing touch brought Palace’s second.

It was the first time Everton had conceded 60-plus goals in a 38-game Premier League campaign.

Everton’s 5-2-3 formation meant they were totally outnumbered in midfield, with Gomes looking well off the pace, and it was no surprise to see him replaced by Dele Alli at half-time.

Having briefly switched to 4-2-1-3 late in the first half, Lampard changed again, with Alli and Alex Iwobi, now in his third role of the night, deployed as two attacking midfielders with Doucoure holding.

Within 10 minutes they had pulled one back when Mason Holgate nodded down a free-kick and Keane lashed home with his weaker left foot.

Pickford’s one-handed save from Mateta kept them in the game, and that was crucial as then came the all-important goals from Richarlison and Calvert-Lewin to keep them in the Premier League.