A new Pope, Leo III, was elected in 795 CE after Adrian died. This pope was nothing like Adrian. Leo III wanted things to be like they were before Charlemagne. He wanted the church to be the supreme power, over not just the spiritual aspects of life, but over all aspects of daily life.
So Pope Leo III started in Rome, where the Vatican (the home of the Pope) was. He started passing laws and issuing decrees taking away the power from the nobles of Rome and giving them back to the church. This caused the nobles of Rome to revolt. Pope Leo was chased out of Rome fleeing for his life.
Pope Leo had to swallow his pride. He had to get back in to Rome, into the Vatican. He was the Pope, the head of the Catholic church. He had to rule from the Vatican. There was no one else, He had to beg Charlemagne for help.
Charlemagne saw this as an opportunity. It was a way to show this new Pope that the King ran the secular part of people's lives while the Pope saw to the spiritual part. It was the way things had been under Adrian. So Charlemagne led his army to help pope Leo. They ended the rebellion very quickly and soon Pope Leo was back in the Vatican.
Pope Leo was grateful, but he still wanted to return the church to power over all aspects of people's lives. But with Charlemagne in power and with the people behind Charlemagne how could he. But Pope Leo saw a way to turn this to his own advantage. He had a plan and he put it in to action.