In an article from 2006 (5 Election L.J. 57), Frederic J. Baumgartner traces the tradition back to a conclave "that began in April 1292 lasted until July 1294":
At a final meeting before disbanding for the summer of 1294, a cardinal read a letter from a hermit, declaring that God had revealed to him that the cardinals would be severely punished if they did not immediately elect a pope. The hermit was known to the cardinals as a saintly miracle worker, and one suddenly nominated him as pope. The others quickly agreed, and 27 months after Nicholas IV died, the hermit was elected as Celestine V. He soon found himself overwhelmed by the burdens of his office, for which he was utterly unprepared. In December 1294, he abdicated. Few events in papal history have been as controversial as Celestine's short reign. Many had viewed his election as the coming of the Angelic Pope who would reform the Church before Christ's Second Coming. Celestine's resignation deeply embittered his supporters, but, rather than blaming him, they accused the cardinals of coercing him. In the quick conclave that followed, the cardinal who played the leading role in persuading Celestine to abdicate was elected as Boniface VIII. ...
Soon after Boniface's election, protests arose that the election was invalid because a pope was not permitted to step down. What should have been only a footnote in papal history became a major controversy because of Boniface's conflict with French king Philip IV, who asked the University of Paris to issue a judgment on whether a pope could abdicate. The Paris theologians concluded that he could not. In 1303 Philip used that decision to send troops to Italy to arrest Boniface as an antipope. The resulting violence broke Boniface's spirit, and he died a month later. Papal memories are very long, and this episode is a factor in making it unlikely that any future pope will resign despite poor health or great age, although the papacy has affirmed that a pope can abdicate.
Interestingly, Baumgartner relates that Pope John Paul II--who famously refused to abdicate despite being disabled in the last years of his reign--affirmed the right of a pope to abdicate in his 1996 amendments to the rules governing conclaves.