Otto I became king of Germany in 936 and was crowned emperor by the pope in 962, establishing the Holy Roman Empire. However, German emperors struggled to control their vassals and argued with the pope over appointments of church officials. This power struggle intensified as Pope Gregory VII banned lay investiture, angering King Henry IV who was excommunicated. After making peace, the struggle over lay investiture continued for 50 years until the Concordat of Worms declared the church had power over bishop elections. Emperors like Frederick Barbarossa also tried to control northern Italian cities, resulting in ongoing conflicts with popes.