I had a class about Pre-Modern Europe, and I recall a particularly fun lecture about the papacy during the late 13th, early 14th centuries, involving a lot of internal struggles between kings and popes, and 3 popes all being pope at the same time.
It all kind of goes down like this: so, during the 13th century, the Popes had a lot going for them. Innocent III establishes the Franciscans, the Domincians, calls about the 4th Crusade, and also the 4th Lateran Council. Meanwhile, England gets its Magna Carta, but still has lay investiture (the king choosing who inherits bishoprics, not the papacy), and so King John is excommunicated. Fearing invasion by the French, King John appeals the Pope, and so England is an official vassal to the Papacy, so that's pretty great.
So the church is expanding and whatnot, being this massive polticial power, but also more corrupt. In particular, papal elections become more fraut with corruption and faction, and it takes 2 years to elect a pope in 1294. This Pope, Celestine, was elected because they needed a pope. After serving 6 months as pope, he passes a decree saying that Popes can resign, and promptly does so (the next would be our own Benedict). The next pope, Boniface, arrests Celestine, accusing him of plotting to become pope again (though he just surrendered it), and Celestine dies in prison.
But here's the fun part: so, Philip IV, the king of France, wants to expand the monarchy's power, and so he denies clerical lawmanship and taxes the clergy to fund the nobility. Boniface doesn't like this, so he sends a messenger to stop Philip from overstepping his boundaries against the church. So Philip arrests the messenger. So Boniface sends a papal order, demanding Philip stop. Philip burns the order. Boniface gets made, declares absolute Papal Power over all humans. Philip's chief minister declares Boniface a heretic. Boniface excommunicates Philip. Philip 's minister leads an army to Rome and Boniface dies after 3 days of imprisonment.
But that's not all: so then the next pope lives only 8 months, and the following Pope, Clement, is a Frenchman from the bishopric of Avignon. Now, it's suspected that Philip rigged Clement's election, but who can say. Now, Philip doesn't want to leave France, so he declares that Avignon is now going to be the home of the papacy. Now, there's conflict between the French popes and the Italian cardinals. England,meanwhile, says fuck it, and decides it's no longer going to be a vassal of the Papacy, because they're basically French puppets.
So, now, after seven French Popes, Pope Gregory returns to Rome in 1377, and dies shortly thereafter. Now, as he is in Rome, the Italians want a Roman Pope that will stay in Rome, but the French dislike that. After the election of Pope Urban of Bari, the cardinals elect another Avignon Pope.
So now we've two Popes, one in Italy, one in France. Some Parisian theologians declare the Pope no longer to be a temporal leader, and so they elect a third Pisan anti-pope, so he's off doing other things. England is independent, and there's some heresy going around in eastern Germany under the name of Jan Huss.
Emperor Sigismund of the Holy Roman Empire doesn't like Huss, and declares a council to discuss theology, inviting Huss himself. Huss comes, and is arrested and executed, because he actually fell for it. Meanwhile, the 3 different Popes all came, and decided to elect a Pope Martin to be a single Pope and everyone else will step down. The Council, however, declares that all popes are under the control of the council (which is later declared a heresy), and it takes some time before all things die out. It's all fun stuff.
Fun fact: Philip VI of France disbanded the Knights Templar, and is the last of the Capetian Kings, one of the largest and longest lasting medieval dynasties.