In the Middle Ages the city was known as Therma or Thermopolis and was often contested between the Bulgarian and Byzantine Empires. It was incorporated in Bulgaria in 705 along with the region Zagora, after it was ceded by the Byzantine emperor Justinian II to the Bulgarian khan Tervel. In 921, during the Byzantine–Bulgarian war of 913–927, the Byzantines launched a campaign that reached the city. The Byzantine commander Pothos Argyros sent a detachment to monitor the movements of the Bulgarians, which was ambushed and defeated by the Bulgarian army.