Cowdenbeath kept up their promotion push thanks to Murray McDowell's second half winner at Borough Briggs. On-loan Ross County midfielder Steven Edwards put Elgin ahead on 13 minutes with a stunning 35-yard strike only for Craig Winter to volley Cowdenbeath level five minutes later with another emphatic finish.
Jimmy Boyle then put the visitors ahead when scored from the spot on 21 minutes to give Craig Levein's men the edge.
City came back into the game however, and moments before half-time captain Colin Milne powered a header past the Cowdenbeath keeper John Martin to bring the home side level at the interval.
Chances were scarce in the second half and it took a fortunate goal to claim victory for Levein's side.
Mick Dowell sent in a weak cross which appeared harmless but the ball somehow beat Elgin goalkeeper Martin Pirie at his near post, leaving no way back for the struggling Highland side.