Burgess Hill Town picked up a miraculous 2-1 victory to remain in the Ryman Premier Division.
Merstham thought they had the last say with an 88th-minute equaliser, but a 98th-minute winner from Sam Fisk saved the Hillians from the drop.
The Hillians needed to win the game and for one of the four teams above them to lose in order for them to survive.
Ian Chapman chose an ambitious lineup with Will Miles starting in central midfield.
Burgess Hill began well by a slip from Ibrahim Diallo allowed in Alex Addai into the box to flash a shot across goal.
The Hillians took the lead on 18 minutes. Aaron Smith-Joseph won Hill a corner which was delivered by Lee Harding and was met by the head of Will Miles to bounce over the keeper.
A Jack Brivio shot was parried by Josh Smith into the path of Tyrell Richardson-Brown, who found the net but was ruled offside. Hill went in at half-time with the neighbouring results going their way.
Burgess Hill had numerous chances to put the game out of sight in the second half. A Richardson-Brown cross was met by the head of Lee Harding, who headed wide from five yards out.
Some sloppy defending at the back from Merstham allowed Richardson-Brown numerous one on ones with the keeper but he could never quite keep his composure to find a finish.
Merstham were piling on the pressure as the Hillians fans watched on nervously knowing a goal would send them down. Ian Chapman made some substitutions, bringing on Hazet for more solidity in midfield and Lucas Rodrigues in the hope of finding a goal on the counter-attack.
Captain Tommy Kavanagh grabbed the dreaded equaliser for Merstham on 88 minutes, beating Lee Harding to the ball and driving the ball into the roof of the net.
The Hillians looked dejected, thinking it was the end and they were going down. A free-kick from Jack Brivio was over the bar and left many thought that was the end of the game. Frustration boiled over as Diallo and Toure were involved in a scuffle in the Hillians half.
Yet the game went on and Hill found one more chance as Brandon Diau found Sam Fisk to head home the winner. Fans flooded the pitch as the full-time whistle blew to keep Hill in the division. It was one of the latest great escapes and the HIllians will be celebrating long into the night.