The oldest sources say the settlement existed in the third period of the Bronze Age. The first records of a former Slavic settlement named "Zunigrod" (present-day Żmigródek) on the north bank of the Barycz River, then held by the Bishop of Wrocław, appear in the library of Pope Adrian IV in 1155. The current city on the other side of the river was invested according to German town law by one "Tydricus dictus Deysenberc" at the behest of the Piast duke Henry III the White in 1253, in a place where there was a ford. The castle near the border with Greater Poland was fortified, surrounded by a strong palisade, ramparts and a moat, there were built two gates, which were abolished only in 1819. The German name "Trachinburg" first appeared in 1287. As a result of the fragmentation of Poland, it was part of various Polish duchies of Lower Silesia: the Duchy of Silesia until 1290, the Duchy of Głogów until 1312 and the Duchy of Oleśnica afterwards, held by the Piast dynasty until 1492.