Henry IV inherited at the age of six the greater German Reich. His father, Henry III was just passed away and he was the oldest son. Henry III had agreed with the German nobility before his death that his son should be King indeed. Because that was at the time not always logical. The Church was just as powerful as the King. Many nobles were also clergy in this epoch. This meant that they heard at the Church. When Henry IV was four years old, he was by the Archbishop of the city of Cologne crowned King.
When Henry IV was 15 years, he was allowed to legally reign. In the epoch of the middle ages, you mature as you 15 years. A year later, he married the girl where he was engaged for 10 years: Bertha of Savoy. In the time that Henry was still too young to be King took his mother for him where. His mother was Regent. But the ecclesiastical power not accepted her reign. Haider mother wanted the power of the Church which is as small as possible. Hendrik and his mother were prosecuted when he was 12 years old. The mother of Henry had to give the power to the bishops. This she did.
Henry IV has had quarrel with the Catholic Church all his life. His father and his mother had always fought against the power of the Church and Henry IV did exactly the same thing. Normally if only the Pope appoint bishops. And only the Pope should someone to Emperor crowns. Henry IV found that he was more important and more powerful than the Pope. He has a lot of bishops appointed. That bishops were faithful to Henry IV. This made the Pope furious.
Pope Gregory VII in 1073 was chosen. Pope Gregory VII wanted to get the power back. Henry and Gregory got in 1076 outright arguing about the appointment of the Bishop of Milan. Naming a Bishop called investiture. For this reason the fight between the Pope and the King called the investiture controversy. This fight was very important for the history of the middle ages. Gregory found that Henry had gone too far and now excommunicated Henry IV. This actually meant that he was declared outlaw. His name and his title were nothing more valuable. No one did more to listen to this Henry.
This showed that the Pope in this period of history still had more power than the King. Henry had to go to Canossa to his regret. Here stood the castle of the Pope. The Pope left him three days before the port to wait before the excommunication was undone.
Nevertheless, Gregory and Henry had not buried the hatchet. Gregory went looking for a replacement for Henry. He wanted to support him to Henry adelen off as King. This resulted in a war. In the year 1084 Henry had had enough. He drove out the Gregory from Rome and appointed itself a new Pope. This new Pope has Henry. So it was that on 34-year-old age Emperor of the Holy Roman Empire.
The investiture controversy lasted until 1122. In this year, the Concordat of Worms. This was an agreement between Pope Calixtus II and the son of Henry IV, Henry V. In this agreement stated that the emperor has no bishops should appoint more. This was the beginning of the separation between Church and State. The bishops were now no longer of course, ruler of an area.