After the death of Bolesław I in 1025 his oldest son Mieszko II was crowned king of Poland. Due to a foreign invasion in 1031 Mieszko went into exile. The military defeat of the young state led to a pagan revolt in 1031–1032. It endangered the newly established Christian church also in Silesia where it ousted the bishop of Wrocław. However, Mieszko regained power in 1032 and restored order. He died in 1034, succeeded by his oldest son Casimir the Restorer. In 1037 a nobles' revolt took place and Casimir fled. This was exploited by a Bohemian Duke, Bretislaus I, who, after pillaging Greater Poland, took control of Silesia in 1038. In 1039 Casimir was back in Poland and started to reunite the country. In 1050, he retook most of Silesia, but was forced to pay tribute to Bohemia. This tribute, 300 Marks per year (later raised to 500 Marks), was the reason for repeated wars between the two countries. Silesia was moreover divided by internal struggles, as some parts of the society were unsatisfied with the changes imposed by Poland. In 1093, the Silesian nobility, supported by Bohemia, revolted. The nobles demanded removal from power of despotic palatine Sieciech as well as recognition of prince Zbigniew of Poland's rights to the Polish crown. The uprising was only partly successful. Zbigniew was officially recognized as heir to the throne. Sieciech however retained power until 1099 and fled the country in 1101. This era of wars and unrest ended with the peace treaty of Kladsko (Polish: Kłodzko) in 1137, in which the border between Bohemia and Silesia was defined and the affiliation of the Kladsko area to Bohemia was confirmed.