However, the pagan unrest led to the transfer of the capital to Kraków in 1038 by Casimir I the Restorer.In 1109, Prince Bolesław III Wrymouth defeated the King of Germany Henry V at the Battle of Hundsfeld, stopping the German march into Poland.
ruler of a territory roughly coextensive with that of present-day Poland, converted to Christianity.
The Kingdom of Poland was founded in 1025, and in 1569 it cemented a longstanding political association with the Grand Duchy of Lithuania by signing the Union of Lublin.
In the middle of the 13th century, the Silesian branch of the Piast dynasty (Henry I the Bearded and Henry II the Pious, ruled 1238–41) nearly succeeded in uniting the Polish lands, but the Mongols invaded the country from the east and defeated the combined Polish forces at the Battle of Legnica where Duke Henry II the Pious died.
In 1320, after a number of earlier unsuccessful attempts by regional rulers at uniting the Polish dukedoms, Władysław I consolidated his power, took the throne and became the first king of a reunified Poland.
His son, Casimir III (reigned 1333–70), has a reputation as one of the greatest Polish kings, and gained wide recognition for improving the country's infrastructure.
Casimir III realized that the nation needed a class of educated people, especially lawyers, who could codify the country's laws and administer the courts and offices.
In 1226, Konrad I of Masovia, one of the regional Piast dukes, invited the Teutonic Knights to help him fight the Baltic Prussian pagans; a decision that led to centuries of warfare with the Knights.
In 1264, the Statute of Kalisz or the General Charter of Jewish Liberties introduced numerous right for the Jews in Poland, leading to a nearly autonomous "nation within a nation".
Poland began to form into a recognizable unitary and territorial entity around the middle of the 10th century under the Piast dynasty.