Following the defeat of the Magyars by Emperor Otto I at the Battle of Lechfeld in 955, Otto's ally Boleslaus I, the Přemyslid ruler of Bohemia, received Moravia. Bolesław I Chrobry of Poland annexed Moravia in 999, and ruled it until 1019, when the Přemyslid prince Bretislaus recaptured it. Since then, Moravia has shared its history with Bohemia. Upon his father's death in 1034, Bretislaus also became the ruler of Bohemia. In 1055, Bretislaus decreed that the Bohemia and Moravia would be inherited together by primogeniture, although he also provided that his younger sons should govern parts (quarters) of Moravia as vassals to his oldest son.