Raith Rovers crashed to a second defeat in four days with a lacklustre performance.
And but for another inspired display by David McGurn in goal and some woeful finishing by Accies, the margin of victory would have been much greater.
Accies, who had lost six of their last eight matches at home in all competitions, were desperate to improve on that dismal record and avoid being drawn into a relegation battle.
They showed positive intent from the off at rain swept New Douglas Park and after just three minutes Grant Anderson swung a cross over from the right, but Mark Stewart’s flashing header drifted wide. Rovers raced to the other end and carved a chance of their own before Jamie Walker drove the ball just past after a low effort from 18-yards.
The Kirkcaldy side had another opportunity after 15 minutes when a flick by Jamie Walker found Allan Walker racing through, but he fired across the face of goal when he should have done better.
Accies were next to threaten when, in 21 minutes, Stephen Hendrie whipped over a superb ball from the left which fell perfectly for Stewart, but his first-time swerving left-foot volley dipped just over.
The Stark’s Park men created a sweeping move in 26 minutes when John Baird’s lung bursting run down the right almost paid dividends, but his cross to Allan Walker was volleyed over in spectacular style.
On 32 minutes Jon McShane laid the ball back to Jim McAlister, but his 20-yard drive took a wicked deflection off Dougie Hill and went just wide with goalkeeper McGurn helpless.
Two minutes later Accies passed up a golden opportunity when Danny Redmond found McShane unmarked eight yards out, but somehow he headed wide.
They finally got the breakthrough in stoppage time when Jon Routledge clipped the ball over from the right, Anderson knocked the ball on and Martin Canning whipped the ball high into net from six yards.
Rovers levelled on the hour mark when Brian Graham cracked a 20-yard free-kick high into the net, the ball taking a deflection off Canning, which left Accies goalkeeper David Hutton helpless.
Three minutes later Accies restored their lead, with a strike which was to prove the winner, when Redmond’s vicious inswinging corner from the right wasn’t cleared by Reece Donaldson and Simon Mensing pounced to lash the ball into the net six yards out for his second goal of the season.
Rovers sit second from bottom of the table and just a point above Ayr United, who lost 4-2 away to Partick Thistle.