The election of Pope Francis back in March of 2013 gave us insight into the process of how new popes are chosen. The Pope is elected through a process in which the College of Cardinals vote by secret ballot for the man they believe would best do the job and a candidate must receive a 2/3rds majority vote to be elected Pope. Throughout this process the cardinals are sequestered in the Sistine Chapel, literally locked in and forbidden from leaving until a new Pope is chosen (unless in the case of emergency). The tradition of the Conclave goes back to the Middle Ages when political infighting led to the longest Papal election in the history of the Catholic Church.
On the 29th of November 1268 Pope Clement IV died, leaving the office of the Papacy empty. The Cardinals convened in Viterbo, Italy, then the home of the Papal seat. At the time there were no codified rules for how the pope was to be elected, Cardinals just kind of showed up, debated a little, and cast their votes. This worked fine for many centuries until the death of Clement IV. At this point in church history a rift was beginning to form between the Italian and French factions of the church. The biggest debate in the election was whether the church would support the Duke of Anjou as King of Naples and Sicily. Both factions were pretty much of equal power, preventing the 2/3rds majority vote necessary to elect a new Pope.
The debates raged on for months, and then years, until eventually the lack of leadership was beginning to sow disunity within the church itself. For the first time since its founding the Roman Catholic Church was beginning to show some cracks. On September of 1270 secular authorities decided to take matters into their own hands. The Prefect of Viterbo (mayor) ordered all the Cardinals to be rounded up by force and assembled at the Palozzo Dei Papi di Viterbo. Once the Cardinals were rounded up and assembled in the Cathedral, all the doors and entranceways were locked, bolted, chained, and barred shut. The Cardinals were told they would be released when they finally settled their differences and elected a new Pope. Food and drink was lowered by basket through the windows. When the conclave continued further their diet was reduced to bread and water only. Despite even further deprivations against the Cardinals the deadlock continued. The Prefect and town magistrates then did something extreme, at the urging of the Duke of Anjou they removed the roof from the Palozzo Dei Papi di Viterbo, exposing the committee to rain, wind, and the elements. Finally on September 1st, 1271, one year after they were locked in the cathedral, and almost three years after the election began, the Cardinals chose Teobaldo Viconti as Pope Gregory X. During this process three cardinals had died and one resigned due to bad health.
The first conclave did little to solve the differences between the French and Italian Catholics, and the rift between the two factions would continue to grow. Eventually it lead to a schism within the church in which there were two Popes, one in Rome and one in Avignon, France. The conclave however would leave a lasting legacy and tradition as Pope Gregory X codified the tactics used by the Magistrates of Viterbo into an official constitution; the Cardinals are to be sequestered behind locked doors and forbidden from leaving until the election is concluded. They are only allowed two servants during this period, after three days they are forbidden from having servants, after five days their diet is to be reduced to bread and water. Today of course the rules have been amended allowing for breaks, snacks, emergency contingencies, and special dispensation for cardinals with health conditions such as diabetes. There are no provisions for removing the roof of the Sistine Chapel in the case of deadlock.