The longest papal reign began when Pope Pius IX was elected.

Giovanni Maria Mastai Ferretti was born in 1792 on Italy’s Adriatic Coast. While he suffered from epileptic fits as a child, he was encouraged to join the church by Pope Pius IIX, an act that would later inspire Ferretti to adopt the Pius name when he became pope. Pope Pius IX reigned for 32 years, longer than all other popes, largely because popes are generally elected quite late in their lives.

Source