During the reign of Bolesław the Brave, relations between Poland and the Holy Roman Empire deteriorated, resulting in a series of wars (1002–1005, 1007–1013, 1015–1018). From 1003–1004 Bolesław intervened militarily in Czech dynastic conflicts. After his forces were removed from Bohemia in 1018, Bolesław retained Moravia. In 1013 the marriage between Bolesław's son Mieszko and Richeza of Lotharingia, the niece of Emperor Otto III and future mother of Casimir I the Restorer, took place. The conflicts with Germany ended in 1018 with the Peace of Bautzen accord, on favorable terms for Bolesław. In the context of the 1018 Kiev expedition, Bolesław took over the western part of Red Ruthenia. In 1025, shortly before his death, Bolesław I the Brave finally succeeded in obtaining the papal permission to crown himself, and became the first king of Poland.