A matter of minutes had elapsed since Raith Rovers had equalised and seemingly denied Partick Thistle two precious points in the Irn-Bru First Division title race but the league leaders had the last laugh to claim a crucial victory at Firhill.
Steven Craig, the on-loan Ross County striker, applied the decisive touch four minutes from time to maintain Thistle's perfect home league record, prodding home from close range after the visitors failed to clear their lines at a corner.
The Firhill crowd erupted as Craig wheeled away to celebrate a goal that sent Jackie McNamara's men two points clear at the top as Dunfermline Athletic could only draw at home to Hamilton Academical.
"I am delighted with the lads and the way we kept going," Thistle manager Jackie McNamara said. "I thought we should have had a penalty before we equalised.
"We have played a lot better and got nothing from games this season. There weren't a lot of guys on top form, but taking three points was the main thing."
The outcome should never have been in doubt after Stuart Bannigan and Steven Lawless had given Thistle a 2-1 half-time lead, one with a powerful low shot from the left side of the area and the other with a sweet strike from the right.
Greig Spence had struck first for Rovers, finishing well after quick thinking from Grant Anderson sent him clean through on goal.
Despite falling behind, the visitors showed admirable spirit as they assumed the ascendency, Brian Graham spurning a chance from 18 yards before seeing a header hit the post and somehow stay out.
The Raith striker bagged his 18th goal of the season with nine minutes remaining, adding the final touch to a frantic passage of play that saw the ball cleared off the line and ricocheting around the Thistle area before falling at the feet of Rovers' top scorer. Ultimately, though, it counted for little.