Five goals, three penalties, a red-card and one man who helped make it all happen: referee Alan Muir.

With Dundee 2-0 up and seemingly on course for a first three points of the season with few questions asked, the whistler took centre stage to turn this run-of-the-mill affair into a case study in why being the man in the middle is the most thankless task in football.

Neil McCann’s side still emerged with the maiden league victory they craved, but the 5000 or so home fans may just have aged a few years in the process.

The manager spoke beforehand about the excellent week his players had enjoyed in training but it’s doubtful much of their meticulous preparation was geared towards handling a second-half spell where things went off-course.

Home debutant A-Jay Leitch-Smith scored either side of the break, one of which came courtesy of a welcome gift from Saints keeper Alan Mannus, and the game appeared to be cantering towards a quiet finish.

That was until Muir got involved. Mind you, although his performance earned him a post-match visit from St Johnstone boss Tommy Wright, he didn’t get it all wrong here. Scott Bain’s ill-judged attempt to beat Graham Cummins to the ball left the official with little choice but to point to the spot and Darren O’Dea had minimal complaint about being shown a second yellow for tussling with Steven Anderson in the box.

However, shortly after Liam Craig stroked home the first of his two penalties, Saints captain Anderson rose highest from a corner and powered a header into the net for 2-2. Or so the visitors thought.

The defender was harshly penalised for an apparent push and the away players' protestations would still have been ringing in Muir’s ears when Leitch-Smith took a tumble at the other end. It looked soft but the spot-kick was given and the visitors’ sense of injustice was compounded.

“If you’re going to give free-kicks for that then everybody’s going to have to start jumping with their arms at their side,” said midfielder Craig. “He’s said it was for a push but you can see from the pictures that it’s minimal.

"If it was up the other end and we’ve won the game 3-2 then they’d be going off their heads about it, so it is disappointing. There’s hardly any contact; he just gets up early.”

After Sofien Moussa fired home from 12 yards, Muir was in action again to penalise O’Dea and give the defender his marching orders. Dundee assistant Graham Gartland soon followed as tensions rose on the touchline.

Although Craig reduced the deficit again there was to be no equaliser for the Perthshire men with Dundee holding on to lift themselves to ninth place in the Premiership table.

Amid the chaos, an impressive Dens Park bow for new boy Leitch-Smith almost slipped under the radar. The Shrewsbury Town loanee was a menace throughout and offers McCann a different option to target man Moussa, even if he can’t wrangle penalty duties off the Tunisian just yet.

“I did want the penalty but there was no getting the ball off Moussa,” Leitch-Smith admitted.

“I grabbed the ball initially, and Darren O’Dea’s come over and taken it off me. I thought he was going to put it on the spot for me but he’s given it to Moussa so I thought, ‘Fair enough!’

“But it was a great start for me but more importantly we got the three points and I thought we looked dangerous throughout.”

The victory could hardly have been timelier for Dundee with champions Celtic set to roll into town on Wednesday for the Betfred Cup quarter-final.

St Johnstone, on the other hand, will feel their unbeaten record was unfairly taken from them as they slipped to their first league defeat of the season.