Gregory XII, (whose birth name was Angelo Correr) served as the bishop of Rome from 1406 to 1415. He resigned to resolve a dispute over who should lead the Catholic Church in The Western Schism times (A.K.A. the split of the catholic church) and died two years after leaving his post.
A Pope's decision to abdicate his post is perfectly legal under Canon Law as "Anyone responsible for oneself (sui compos) can resign from an ecclesiastical office for a just cause."
While the news of Pope Benedict-XVI's resignation came as a striking surprise, this is not the first time a pope gives up his position. According to the Vatican, John Paul II had secret letters offering to resign if he became unable to fulfill his task as head of the Catholic Church.
In his resignation statement, Pope Benedict XVI said he had to "recognize his incapacity to adequately fulfill the ministry entrusted to him," which is why he'd be leaving his post on Feb. 2013 at 8 p.m.
Other popes who have resigned include:
Gregory XII (1406-15) To put an end to the Great Western Schism.
Celestine V (1294) Abdicated the papacy and was imprisoned by his successor.
Gregory VI (1045-46) Left the post after being accused of purchasing to papacy and freely admitting to it.
Benedict IX (1032-45) Resigned after selling the papacy to his godfather Gregory VI. One of the few men to have been pope more than once.
Benedict V (964) His papacy was overthrown by emperor Otto I.
Martin I (649-655) Abducted by Emperor Constans II. He is considered a martyr by the Catholic Church.
Marcellinus (296-304) Deposed after complying with Roman Emperor Diocletian's order to offer sacrifice to pagan gods.
Pontian (230-235) The first pope to ever abdicate his post. He allegedly resigned after being exiled.