Elgin triumphed by the odd goal in five at Borough Briggs to put the brakes on Arbroath's promotion march.
A dour first half was more than made up for by a goal-fest in the second as City got revenge for defeat in Arbroath just three days ago, triumphing 3-2.
It was the Red Lichties who opened the scoring after 52 minutes when Gavin Swankie played a free-kick into the box which he had won and Keith Gibson headed home.
The score was level nine minutes later when Jason Crooks found himself in space six yards out which he duly took advantage of with a low strike.
Elgin went ahead in the 74th minute when goalscorer Crooks turned provider with a cross for Mark Nicholson to fire in the top corner from 18 yards.
City were 3-1 up just two minutes later when Ross O'Donoghue's 18-yard shot beat Arbroath goalkeeper Darren Hill at his near post.
Adam Strachan's effort from 12 yards reduced the deficit for the visitors to make it a nervy last six minutes but Elgin hung on.