In the video game Crusader Kings II, a bishop's claim to a kingdom could be militarily pressed so that the bishop would become a "king-bishop", as distinct from a prince-bishop, who ruled smaller realms.
Was there ever a priest or bishop who ruled a kingdom by his own right?
There was a Cardinal King, king Henry of Portugal who ruled for a brief time from 1578 to 1580. Henry was one of the younger sons of king Manuel I, brother of future king João III. With having little prospect to inherit the crown, he was sent to make a career in Church where he, unsurprisingly, advanced quickly. He was made archbishop of Braga at 21 and cardinal at 33 (which is still much slower than his other older brother Affonso who was made bishop and cardinal by the age of 7)
João III had a long and relatively successful reign, but was very unfortunate as all of his sons died young, most as infants and young children. The only son who reached adulthood, João Manuel, died in 1554 few years before his father João III, but also just few days before his only son Sebastian was born. This put young child Sebastian as successor to his grandfather João III.
When João III died in 1557, Sebastian was still only 3 years old, and his great-uncle Cardinal Henry was made first co-regent with his mother, but then sole regent until Sebastian accession to full rule in 1568.
In 1578, young and rash, and importantly heirless Sebastian got himself evolved in dynastic disputes in Morocco. Ottoman backed pretenders to the throne disposed previous rulers of Morocco, which in turn then came to Portugal and Spain to get support for reconquest. Phillip II of Spain was more tactfully full of promises but short on actually doing anything, while Sebastian for some reason took the call.
Portugal had string of forts, and some dreams of full conquest, in Morocco since 1415, but by the time of João III, it was deemed that many of them are useless and drain of resources and were gradually withdrawn from. It seems Sebastian wanted to restart the conquest and called for a crusade. He assembled an army and personally led it in combat, to the famous battle of Alcácer Quibir, Battle of Three Kings. There, the Portuguese were crushingly defeated and King Sebastian disappeared without an heir.
The next (and only clear) in line was Sebastian' 66-year grand-uncle Cardinal Henry, who seemingly without enthusiasm, resigned his arch-bishop position (but not the church vows) and took the throne. In his short reign he was mostly preoccupied with the fallout of Alcácer Quibir, which, among leaving the army crushed and people demoralized, left plenty of Portuguese nobles and soldiers in Moroccan captivity and Henry took to ransoming them back at huge cost, seriously depleting the treasury.
He, also rather unwillingly, took upon asking the Pope to be released from his church and celibacy vows so he can take a wife and make an heir which Portugal desperately needed. The Pope refused this request, probably under pressure from Phillip II who himself had a very serious chance to claim the Portuguese throne.
Soon, the cardinal-king Henry died, and left the position of heir open. Several contenders appeared, but the main seemed to be Dom Antonio, illegitimate son of one of João III brothers, and Phillip II of Spain through his maternal line - while in Portugal male line had priority. João III was illegitimate (which both was and wasn't an issue) and seemingly unpopular, and could not compete with Phillip II, who using his money, power and influence to get nobility on his side. Then Philip directly sent an army into Portugal which defeated the smallish army of Dom Antonio, and Portuguese Cortez proclaimed Phillip II king whoch brought about Iberian Union of Spain in Portugal (which lasted till 1640). Dom Antonio escaped to France from where he briefly took Azores, and then to England where he became a pawn in conflict between Elizabeth I and Phillip II. Following the failure of Spanish Armada in 1588, Elizabeth used Antonio's claim to the Portuguese throne to launch an invasion of Iberia. The goal was to get Antonio to start a wide scale rebellion in Portugal, but upon landing Portugal no such thing happened and with lack of popular support the attack miserably failed.
Sorry, the answer is mostly about the events before and after the reign of Cardinal Henry, which is consequence of the very short length of his rule, and the importance of those events both on his rule and on the developments of the greater scale.