In the 14th century Lelów prospered, due to royal protection and privileges. Its population reached 1,200, and King Casimir III the Great built here a castle, and surrounded the town with a defensive wall. Lelów was located near the border with Czech-ruled Silesia, and as such, played an important role in the system of defence of Poland. In 1341 Lelów received Magdeburg rights from King Casimir, and became a county town in Kraków Voivodeship. In July 1345, during the Polish-Bohemian War, Czech units were defeated by the Poles and their Hungarian allies near Lelów. In the 15th and 16th centuries, Lelów remained one of the most important towns of Lesser Poland. It frequently burned, but managed to recover, and local cloth makers were famous across the country. In 1638 Lelów almost completely burned in a great fire, and further destruction was brought by the Swedish-Polish war, after which the town never recovered. Lelów was once again destroyed in the Great Northern War, after which its defensive wall was pulled down.