The town was liberated on 24 November 1877 by Russian forces under Joseph Vladimirovich Gourko during the Russo-Turkish War of 1877-78 and served as a governing centre for the 40-day winter march of the Balkan Mountains of the Imperial Russian Army .