Long-serving Skelton fired into the top corner with the last kick of the match as the club threatened with closure clinched only their fifth win of the season.
Substitute goalkeeper Artur Krysiak had pulled off a superb save to deny 10-man Hearts and Gretna now need a late rescue off the pitch with a buyer needed by the weekend.
Hearts’ hopes of ending their season on a high were hit by teenager Gary Glen’s first-half red card and the defeat leaves them in eighth place.
Just two years ago Hearts beat Gretna on penalties in a thrilling Scottish Cup final with both clubs looking like two teams on the rise.
But the 1,090 crowd at Fir Park was in stark contrast to the 50,000 fans who watched that occasion, as grim seasons hit by managerial changes and massive debts came to a close for both sides.
Before the game Skelton – who joined the club when they were in the Unibond League – was presented with a gift for his commitment to the cause by Gretna supporters.
But a section of fans reserved abuse for former chief executive Graeme Muir, who resigned after the club went into administration in March.
Also present was ex-manager Rowan Alexander, who helped the club rise from the Third Division to the top flight before his acrimonious departure.
Gretna created the game’s first chances but Nicky Deverdics volleyed well wide and Brendan McGill mis-hit another effort.
Deverdics missed a glorious chance in the 15th minute when he sliced wide from 12 yards after Hearts defender Christos Karipidis had completely missed a low cross by Rhys Meynell.
Hearts’ hopes were rocked in the 26th minute when Glen kicked Barr in the chest as the pair tangled on the ground, earning a straight red card.
Skelton was lucky not to follow Glen down the tunnel when he aimed a kick at Laryea Kingston after being fouled by the Ghana midfielder.
Barr headed straight at Steve Banks after Deverdics had curled in the resulting free-kick before the visitors forced Greg Fleming into his first save as he dived to push out a low drive by Fernando Screpis.
Kingston fired a long-range effort inches wide before Rostyn Griffiths put the ball in the net from a McGill cross only for Gretna’s celebrations to be ended by an offside flag.
Gretna continued to push forward after the interval but they were nearly caught on the break before Fleming did well to close down Mole, who lobbed well over.
The unmarked Meynell headed straight at Banks following Hall’s cross and Deverdics volleyed over after a decent move from right to left.
Hearts came back into it and Gretna substitute keeper Artur Krysiak blocked well at his near post from both Mole and Kingston.
The visitors lost Marius Zaliukas in the 73rd minute to what looked like a serious head injury with young Ryan McGowan coming on.
Hearts finished the stronger side but Krysiak pulled off a spectacular stop from Kestutis Ivaskevicius after the substitute had sidefooted Kingston’s low cross towards the corner from six yards.
But, after almost four minutes of injury time, Skelton repaid the fans for their gift when he fired into the top corner from 16 yards.
The dramatic end was typical of Gretna’s recent history, and their fans hailed the players after they maintained a proud end to their doomed SPL stay with just one defeat in six matches.