Jake Walker was sprung from the bench to score the first league goal of his career as St Patrick's Athletic left it late to finally put Finn Harps away in their SSE Airtricity League clash at Richmond Park.
Just their second win in nine games, the result moves Harry Kenny's side level on points with fourth-placed Derry City, though with two more games played.
A fifth straight loss keeps Harps bottom.
Decidedly edgy at the back from the start, Harps lived dangerously as they struggled to deal with Simon Madden's crosses into their area.
Chris Forrester headed wide inside two minutes before a right scramble in the visitors' box a minute later saw Mikey Drennan and Gary Shaw have shots frantically blocked.
Having survived, a mistake at the other end almost gifted Harps the lead on 17 minutes.
Drennan was cleverly dispossessed by Raff Cretaro who then threaded a sublime ball through for the run of Nathan Boyle. Brendan Clarke was promptly off his line to avert the danger, saving with his feet.
St Pat's striker Drennan might have made amends for his error back at the other end 10 minutes later, but merely managed to direct his header straight at keeper Mark McGinley from another excellent Madden delivery.
After a relatively lively opening, the game went flat for much of the remainder of the first half, Harps creating a half chance on 44 minutes.
Skipper Keith Cowan headed Gareth Harkin's fee kick across goal where Boyle's hooked volley was off target.
St Pat's began the second half as they did the first on the front foot.
Cian Coleman flicked a header off target from a Madden cross a minute in.
Kevin Toner then fired a shot into the arms of McGinley after Conor Clifford's are kick deflected off the defensive wall into his path.
But, as in the first half, it was Clarke who had to make the first telling save of the second.
Mikey Place got in one-on-one with his shot parried off the body of the St Pat's keeper. Boyle then saw his follow-up from the rebound deflected for a corner.
Having rode their luck, St Pat's sparked to life back at the other end with Drennan's shot from distance tipped over by McGinley leading to a spell of four corners.
And they finally got their reward on 83 minutes.
Fellow substitute Dean Clarke got free on the right from Lee Desmond's ball to pick out 20-year-old Walker who swept the ball home off a post with his right foot.
Drennan might have added to that on 90 minutes but for a terrific save from McGinley.