Aberdeen made it 500 goals in 321 games under Derek McInnes but despite scoring twice to defeat St Mirren and reach that milestone, it almost was not enough.
Captain Joe Lewis looked to have cost his side victory when he conceded a late penalty only to redeem himself in spectacular fashion with a double save to ensure Niall McGinn’s honour of scoring the 500th goal of McInnes’ reign earned all three points.
Dons boss McInnes saluted his captain for making amends for his error.
He said: “St Mirren had a chance from 12 yards and didn’t take it thanks to Joe. He showed why he is so invaluable to us and when you have someone like him and Sam Cosgrove at the other end you always have a chance of winning games.
“It’s no secret we’re short of natural midfielders at the minute and it showed at times.
“We scored a good goal, should have got another from Lewis Ferguson which seemed harder to miss than score, and some of our play was really good but we lost a really cheap goal and didn’t respond well.
“There’s a wee fragility about us and we had to reset. We made a subtle change at half-time by putting McGinn out in a wider area and it proved pivotal.”
The Dons boss opted for a back three for the Saints’ visit and there was less than a minute on the clock when the visitors came close to capitalising.
Lewis was called into action and made a terrific block to deny Tony Andreu putting the visitors ahead after the midfielder had been sent clear by Saints striker Sam Foley.
Aberdeen heeded the early warning by opening the scoring with their first attempt.
There were only six minutes on the clock when Jon Gallagher found Ryan Hedges in space in the box. The Wales international’s cross was headed clear as far as Cosgrove and the striker took a touch before firing past Vaclav Hladky for his 18th goal of the season.
The Dons formation made for some rollercoaster viewing at times with both sides carrying a threat but Ferguson should have made it 2-0 from a Zak Vyner cross but he failed to hit the target with his diving header from six yards.
How crucial a miss it was became evident less than a minute later when Ryan Flynn’s terrific run down the right wing took him to the byeline before he crossed for Jonathan Obika to score for Saints.
It was no less than the Saints deserved against an Aberdeen defence that looked anything but comfortable.
It nearly got worse for the home side too as Sean McLoughlin rose above Lewis to head a corner over the crossbar as the visitors threatened a second.
The pattern continued to the break with the Dons looking a threat, but at the cost of being far too open defensively.
Andreu fired over after Aberdeen’s defence failed to close him down while Cosgrove had a header cleared off the line and McGinn saw his shot blocked by McLoughlin.
Aberdeen came out for the second half with renewed energy and determination and they were rewarded within 10 minutes of the restart.
Ferguson’s flick released Hedges down the left and he recovered from a challenge to race into the box before cutting the ball back to McGinn who hammered the ball high into the net from 12 yards.
Saints remained as game as they were in the first half but crucially they found the space they had enjoyed to trouble the Dons during the first half was no longer available and Lewis was seldom tested. That all changed six minutes from time when the Dons conceded a penalty after Obika, having beaten the offside trap, went down in the box under a challenge from Lewis.
The Dons captain was booked following the decision but redeemed himself when he dived low to his right to parry Andreu’s spot kick before saving the rebound to earn his side all three points.
Next up for the Dons are Rangers on Wednesday and McInnes has challenged his players to offer more of a fight than they showed in their 5-0 defeat at Ibrox when the sides last met.
He said: “The determination of the players has been far better and much needed at this stage of the season.
“Four wins and a draw out of five games is no bad shooting and now we face one of the strongest teams in the country.
“Rangers are a better team than us with better players but we believe we can win the game if we let them know they are in a game.”