Henry IV came into power at a time when the position of an emperor had lost the level of power former emperors had held. Gregory VII became pope during the country's weakened state, and this provided him with power that surpassed Henry IV. Henry IV needed the support of the church, much to his dismay. The two struggled over who would have the greatest control.
Gregory VII further agitated Henry IV by removing the power from the emperor to appoint bishops. The pope further yielded his power by excommunicating Henry and demanding he do penance for his sins against the church. Henry IV was infuriated and vowed to take back control that emperors formerly held.
However, with his country in rebellion and the people split, Henry struggled with the situation. Henry traveled to the pope and feigned that he was repentant. In reality, he identified the pope as his enemy.
When Henry IV had experienced enough problems with the pope, and his legion was strong, he laid siege to Rome and removed Gregory VII from his position. He then appointed a pope of his choosing and demonstrated dominance over the pope. Pope Gregory, now removed, escaped to Salerno. He never gained his power back. Henry's ability to bring an army on Rome and dethrone the pope proved he had more power than the pope.