Poland began to form into a recognizable unitary and territorial entity around the middle of the 10th century under the Piast dynasty. Poland's first historically documented ruler, Mieszko I, accepted Western Christianity as the rightful religion under the auspices of the Latin Church with the Baptism of Poland in 966 AD. In 1000, Boleslaus I the Brave, continuing the policy of his father Mieszko, held a diplomatic congress and established the metropolis of Gniezno followed by dioceses in Kraków, Kołobrzeg, and Wrocław. Otto III, Holy Roman Emperor, assented to the creation of bishoprics and bestowed upon Boleslaus royal regalia and a replica of the Holy Lance, which were used for his coronation as the first King of Poland in circa 1025. He expanded the realm considerably by seizing parts of German Lusatia, Czech Moravia, Upper Hungary and the eastern provinces. However, the transition from paganism proved difficult and was not an instantaneous process for the rest of the population as evident from the pagan reaction of the 1030s. His son, Mieszko II Lambert, lost the title of king and fled amidst the struggles for power in 1031, but was reinstated as duke in 1032. The unrest led to the transfer of the capital to Kraków in 1038 by Casimir I the Restorer.