In Game of Thrones, an interesting thing happens - mild spoiler alert - a royal figure gives a very honest, humble, devout religious leader the ability to act sort of as a military leader for "the gods". This figure then turns this power immediately onto the most powerful figures in government, locks them up, and puts them trough terrible punishment until they admit to sins (that they were guilty of). It's just very interesting how extremely fast this happens. The religious figure is given permission to physically punish those who sin, and the very person who gave the religious leader power is the one its being used on, with severity. Suddenly this religious figure is nearly as powerful as the king himself.
Has this phenomenon ever happened in medieval times? I know about the Crusades, but I dont know specifically if they could be compared to this particular situation, as this happens locally, not where a religious leader sends crusaders to attack some distant land.
I'm looking for an answer detailing a particular royal figure being brutally punished for sins by a religious leader.