The castle lies on a hill at the northeastern side of the city, and was first built, according to Procopius of Caesarea, by Emperor Justinian I (r. 527-565) on the ruins of the acropolis of the ancient city of Trikke. In its current form it largely dates from the Palaiologan period, where it was extensively rebuilt and remodelled. The citadel suffered much damage during its conquest by the Ottoman Turks in 1393/4, but the city's importance as a bulwark against the restless inhabitants of the Pindus mountains and the Agrafa region, as well as being the centre of the Ottoman administration in Thessaly, meant that it was quickly repaired and strengthened. The castle suffered damage and was repaired after the failed rebellions of 1854 and 1878 against Ottoman rule.