The settlement probably already existed in the 11th century. In the High Middle Ages, together with the Kłodzko Land, it changed affiliation several times, passing between Poland and Bohemia. A church at the site was first mentioned in 1290. That same year, after the death of Polish duke Henryk IV Probus Kłodzko Land passed to Bohemia. It was granted town rights around 1320-1333. From 1327 to 1341 it was placed under the rule of Polish dukes from the Piast dynasty (within the duchies of Wrocław and Ziębice) and in 1348 it was incorporated to the Bohemian Crown Lands. By 1373 the town had a mayor and in the early 15th century defensive walls were built. Then in 1418 it received new privileges from King Wenceslaus IV, which equated its town rights with those of Kłodzko and granted the title of a royal city. In the following decades, the town was devastated by Hussite troops in 1425 as well as by the Hungarian forces of king Matthias Corvinus in 1469. In the 15th century, crafts flourished, local cloths were exported to other countries, while 85 of all 86 houses had the right to brew beer.