In the late 13th century Częstochowa became the seat of a Roman Catholic parish church, which was under the Lelów deanery. The village was located in the northwestern corner of Kraków Land, Lesser Poland, near the Royal Castle at Olsztyn. Częstochowa developed along a busy merchant road from Lesser Poland to Greater Poland. The village was ruled by a starosta, who stayed at the Olsztyn Castle. It is not known when Częstochowa was granted a town charter, as no documents have been preserved. It happened sometime between 1356 and 1377. In 1502, King Alexander Jagiellon granted a new charter, based on Magdeburg rights to Częstochowa. In 1382 the Paulist monastery of Jasna Góra was founded by Vladislaus II of Opole – the Polish Piast prince of Upper Silesia. Two years later the monastery received its now-famous Black Madonna icon of the Virgin Mary; in subsequent years became a centre of pilgrimage, contributing to the growth of the adjacent town. Częstochowa prospered in the late 15th and early 16th centuries, due to efforts of Sigismund I the Old, the future king of Polish–Lithuanian Commonwealth. At that time, Sigismund ruled the Duchy of Głogów, and frequently visited Częstochowa on his way to the Duchies of Silesia (1498, 1502, 1502, 1503, 1505, 1505, 1506). In 1504, Częstochowa was granted the right to collect tolls on the Warta river bridge. In 1508, Częstochowa was allowed to organise one fair a year; in 1564, the number of fairs was increased to three annually, and in 1639 to six. In the year 1631, Częstochowa had 399 houses, but at the same time, several residents died in a plague, after which 78 houses were abandoned. In the first half of the 17th century, kings of the House of Vasa turned the Jasna Góra Monastery into a modern Dutch-style fortress. During the Swedish invasion of Poland in 1655, the monastery was one of the pockets of Polish resistance against the Swedish armies (for more information, see Siege of Jasna Góra). The town of Częstochowa was almost completely destroyed by Swedish soldiers. It has been estimated that the town lost 50% of the population, and 60% of houses. But the town suffered less severe destruction than such area towns as Przyrów, Olsztyn and Mstów. It took several years for Częstochowa to recover from extensive losses. As late as in the 1680s there still were ruined houses in the town.