A clerical reform movement, which had its roots in the 10th century, in the cloister of Cluny, had demanded that the church free itself from the influence of laymen. In its wake, the relationship between the emperor and the pope in Rome was almost reversed.
While initially, the emperor saw his role in the protection of the church (and assumed the title of emperor as a formal acclamation in return), the pope now began to claim a superior role for himself in several respects: not only did he demand the right to appoint all clergy in the Empire (who frequently had important political functions), but also claimed a right to select (and unseat) the emperor himself.
The details are complex, but the controversy culminated in 1075, when Pope Gregory VII formally prohibited Emperor Henry IV in the Dictatus Papae to appoint bishops at all. In 1076, both sides made use of their most powerful weapons, respectively: the emperor declared the pope unseated, the pope in turn declared a clerical ban on the emperor (which relieved all dukes in the Empire from their oaths to the emperor, in fact thus unseating him as well). In the famous 1077 Walk to Canossa, Henry IV formally asked the pope for forgiveness and thus forced him to take back the ban.
The controversy was only formally resolved many years later, with the Concordat of Worms in 1122.