The history of Łańcut is much older than the castle erected in 1642. It goes back to the times of King Casimir III the Great, who founded here a town in accordance with the Magdeburg Rights in the 14th century. At the time Łańcut was owned by the Pilecki family, who had connections with the royal Jagiellonian Dynasty. The head of the family, Otton Pilecki, was a close friend of the king and his wife, Jadwiga, became the godmother to the future successor, Władysław II Jagiełło (1352-1434). Later the connections were strengthened with their daughter Elżbieta's marriage to the king. Władysław II Jagiełło is believed to have visited Łańcut twice. Between World War I and World War II, the local townspeople still pointed to a lime tree growing on a hill, a former site of the Pilecki's wooden fortified mansion, where the king was believed to have relaxed with his third wife Elżbieta. After the Pilecki clan has died out, Łańcut became the property of the Stadnicki family. The most famous of them was Stanisław, the governor of Sigulda. Stadnicki extended and modernised the castle in 1610 during the reign of Sigismund III.