The Jags looked to be in control after first-half goals from Kenny Miller and Raffaele De Vita but David Hopkin's men scored three times in the space of just eight minutes to climb to second place in the table.
Nicky Cadden started the comeback with a free-kick in 72 minutes that keeper Scott Fox helped into the net and John Sutton equalised from close range before Brian McLean headed the winner from a Lewis Strapp long throw.