Aberdeen Grammar handed themselves an outside chance of saving their league season when they rose to the occasion with a first win in 12 matches to give new coach Ali O'Connor an immediate success.
However, Grammar also fell short of a much-needed try bonus point.
After the misery of a run of defeats which went back to late October, a four-point win was more than acceptable to the new coach, who replaced Stuart Corsar during the week.
O'Connor said: "The motivation has been great all week, carrying on into the game. We scrapped for every ball and need to carry this form into our last three games, starting with GHA in Glasgow next week."
The much-needed win was all the more remarkable as Grammar had to come back from behind twice to see off the challenge of sixth-placed Stewart's Melville who, early in the game, held all the aces in a big dominant pack who took the game to the home side.
The visitors went in front in 15 minutes when centre Ali Grieg took advantage of poor defending in the Grammar back division to race over. Michael Hanning kicked the conversion.
Grammar rallied and flanker Ali Mackie plunged over near the posts, giving captain Alex Hagart the easiest of kicks to level.
Playing with the breeze, the Inverleith side pulled ahead four minutes after the break when Adam Howie rumbled across the Grammar line, sending a shiver of apprehension through the home crowd, especially as Manning added the conversion.
Instead of buckling, Grammar emerged as an attacking force, easing back into the game with a Hagart penalty to reduce the gap to four points, leading to an inspired seven-minute spell in which Sam Knudson breached the visitors line, followed by another Hagart penalty to give Grammar an 18-14 lead.
It became 25-14 when Peceli Nacamavuto combined with Hagart for a try to which the captain added the extras. The visitors were now a spent force, stunned by Grammar's new-found ferocity.
"On this form we can will all our remaining games," said winger Grant Walker, whose tackles were an inspiration to his younger colleagues.
© Jack Nixon
Aberdeen Grammar: Sam Knudson; Grant Walker, Alex Ratcliffe, Peceli Nacamavuto, Martin McRobbie; Alex Hagart, Andrew Ovenstone; Colin Neilson, Stuart Davis, Chris Prentice; Calum Champion, Robin Cessford; Ali Mackie, Tony McGinness, Adrian Hamilton.
Replacements: Duncan Massey, Mike Cox, Christian Brew, Ali Addy, Calum Ruxton.
Stewart's Melville: Ciaran Whyte; James Ferguson, Ali Greig, Angus Rennie, Sean Murchie; Michael Hanning, Andrew Manson; Willie Aitkin, Ruaidh Mitchell, Angus Wallace; Fraser Morrison, Alex Rappestad; Jamie Berrisford, Hugh Lindsey, Adam Howie.
Replacements: Rhys Morgan, Ali Pollock, Scott MacColl, Fraser Strachan, Ross McCann.