Charlemagne was a devout christian and a ruler His goal was to earn the name of an emperor. Charlemagne and the pope worked together because the pope crowned charlemagne emperor and charlemagne would travel to rome to support the pope. The pope rewarded charlemagne by crowning him as an emperor.
I own you and you will always be controled by a king
I will control you and you will listen
Charlemagne believed that god had made him emperor in order to do god's work on earth. The pope believed that it was his duty to assist him in that work. 200 years later Charlemagne's coronation lead to a dramatic clash between the emperor and the pope.
We need to settle this
Pope Gregory had been a monk and then had become a pope in 1073. King henry lV reacted by a threat to his own power and rights.
We can share to power
The conflict between them was that Pope Gregory tried to dethrone the emperor from his throne and all of his power and the Pope would take his place. The people across Europe reacted to it because members of clergy and secular rulers took sides.
The Pope and the King had to stop the fighting and find a way to stop the conflict. They had agreed to stop and let the king rule his lands but the Pope was to be incharge of the churches.
The conflict ended between the two because they had died and eventually in 1122 the church had made an agreement called the concordat of worms. The concordat of worms gave the church the sole authority to appoint bishops. Also allowed emperors to give fiefs, or grant of land, to bishops in order to win their loyalty.