Until 1795 , Poland was ruled at various times either by dukes (ca. 960 – 1025 , 1032 – 1076 , 1079 – 1295 , 1296 – 1300 and 1306 – 1320 ) or by kings ( 1025 – 1031 , 1076 – 1079 , 1295 – 1296 , 1300 – 1306 and 1320 – 1795 ). The best-known dynasties are the Piast (ca. 960 – 1370 ) and Jagiellon ( 1386 – 1572 ) dynasties. Intervening and subsequent monarchs were often also rulers of neighboring lands, or princes recruited from foreign dynasties. Polish independence ended with the Third Partition ( 1795 ) and was restored in 1918 on a republican basis.