The Steelmen had a comfortable advantage when Michael Higdon took his tally to 16 for the season with a hat-trick.
But the hosts required a crucial save from Lee Hollis in the dying minutes to secure the win, after the keeper had come on as a substitute for Darren Randolph, who sustained a hamstring injury.
Hollis had endured a tough start to his game when he conceded twice in as many minutes to goals from Nigel Hasselbaink and Liam Craig.
"It was a really good goal by Hasselbaink and with the players they have in their team, especially in attacking areas, I always think they will be a threat," he said.
"I don't think it was a case of switching off. I felt for Lee Hollis who said he felt a bit like an idiot, he just walked on the park and two goals had flown by him.
"But even if Darren had been in, they were two really good goals. He made a crucial save at the end and a home win against rivals for a top-six spot, we have to be grateful."