The history of Poland originates in the migrations of Slavs who established permanent settlements in the Polish lands during the Early Middle Ages. The first ruling dynasty, the Piasts, emerged by the 10th century AD. Duke Mieszko I (d. 992) is considered the de facto creator of the Polish state and is widely recognized for the widespread adoption of Western Christianity that followed his baptism in 966. The duchy of Poland that Mieszko ruled was formally reconstituted as a medieval kingdom in 1025 by his son Bolesław I Chrobry. Perhaps the most successful of the Piast kings was the last one, Casimir the Great, who presided over a brilliant period of economic prosperity and territorial aggrandizement before his death in 1370 without male heirs. The period of the Jagiellonian dynasty in the 14th–16th centuries brought close ties with the Grand Duchy of Lithuania, a cultural Renaissance in Poland and continued territorial expansion that culminated in the establishment of the Polish–Lithuanian Commonwealth in 1569.
In its early phases, the Commonwealth was able to sustain the levels of prosperity achieved during the Jagiellonian period through its remarkable development of a sophisticated noble democracy. From the mid-17th century, however, the huge state entered a period of decline caused by devastating wars and the deterioration of its political system. Significant internal reforms were introduced during the later part of the 18th century, especially in the Constitution of May 3, 1791, but neighboring powers did not allow the reform process to advance. The independent existence of the Commonwealth ended in 1795 after a series of invasions and partitions of Polish territory carried out by the Russian Empire, the Kingdom of Prussia, and the Austrian Habsburg Monarchy.