VATICAN CITY -- When Cardinal Jorge Mario Bergoglio almost became pope in 2005, he told a confidant that -- had he been elected -- he would have named himself after the pope he so admired: John XXIII.
When he did become pope in 2013, his first public words echoed what John Paul II had said upon his election -- that cardinals had searched far, to the "ends of the Earth," to find a new leader.
John XXIII and John Paul II, two of the 20th century's great spiritual leaders, changed the face of the Catholic Church and the papacy itself with their remarkable, and remarkably different, papacies. They also had a profound influence on Pope Francis, who will declare them both saints Sunday in history's first canonization of two popes.
John, embraced by progressives, reigned from 1958 to 1963 and is credited primarily with having convened the Second Vatican Council, which brought the 2,000-year-old institution into modern times. During his 26 years as pope, John Paul ensured a more conservative implementation and interpretation of the council, while helping to bring down communism and energizing a new generation of Catholics.
Just weeks after he was elected, Francis prayed at the tombs of both men -- an indication that he feels a great personal and spiritual continuity with them.
"To canonize them both together will be, I believe, a message for the church," Francis said last summer. "These two were wonderful, both of them."
Francis owes his papacy -- and his career -- to John Paul, who was elected in 1978 as the first non-Italian in 455 years.
It was John Paul who plucked Bergoglio from relative obscurity and from internal Jesuit exile to make him an auxiliary bishop of Buenos Aires in 1992. Six years later, John Paul promoted Bergoglio to archbishop of the Argentine capital and in 2001 made him a cardinal, putting him in the running to possibly succeed him as pope.
In Bergoglio, John Paul probably saw a kindred spirit, a conservative who like John Paul opposed the Marxist excesses of liberation theology in Latin America.
Bergoglio later testified before the church tribunal for John Paul's saint-making process that his pope had been "heroic" in his suffering as he battled Parkinson's disease in his later years. He said his own devotion to the Virgin Mary was due in part to John Paul's great devotion to the Madonna.
But in many ways, Francis is much more a pontiff in the style of John XXIII.
Francis' emphasis on a "poor church," on internal church reform and spreading the faith to the peripheries of society echoes the concerns of John XXIII.
The young Angelo Roncalli joined the Franciscan order's lay branch before being ordained, drawn to the emphasis of its founder St. Francis of Assisi on caring for the poor and his message of peace. The current pope eventually decided to name himself after St. Francis, signaling a deep spiritual connection.
In a sentimental sign of his admiration for John XXIII, Francis included John's longtime private secretary, Loris Capovilla, in his first batch of new cardinals, even though at age 98 Capovilla was well over the age limit to vote in a conclave.
Francis was similarly so determined to see John made a saint that he broke the Vatican's own rules for canonization, declaring that the Vatican need not go through the process of certifying a second miracle attributed to his intercession.
"Francis is a Roncallian pope," said Alberto Melloni, John's biographer and the head of the Bologna foundation where his papers are kept. "We see the fruit of the council today in Pope Francis."
Francis is a pastor pope like John, and less doctrinaire than John Paul.
Francis once quipped, when asked why he didn't raise abortion and same-sex marriage during his first foreign trip to Brazil, that he didn't feel it necessary -- "just as I didn't speak about cheating, lying, or other matters on which the church has a clear teaching!"
Had John Paul not spent the better part of a quarter-century clarifying church teaching on issues such as abortion, euthanasia and homosexuality for a generation of Catholics confused after the turbulent 1960s, Francis perhaps might not have felt that way. But the remark also points to Francis' forgiving focus on mercy over morals.
That's not to say that John Paul was all doctrine. On the contrary, his globe-trotting papacy, his foresight to launch the wildly popular World Youth Days and his natural ability to communicate all made him the world's Catholic pastor on a global altar.
That too has influenced Francis, who seems to have a similarly easy, casual way of dealing with young people, though he lacks the booming voice John Paul cultivated in his days as an actor.
George Weigel, John Paul's biographer, said it's "frankly ridiculous" to see Francis only as a rupture from the doctrine-minded papacies of John Paul and later Benedict XVI, as many people view him.
"Pope Francis is obviously a man who is inspired by John Paul II, deeply admired John Paul II," Weigel said. "He inherited a church shaped by John Paul II and Benedict XVI in what I try to think of as a 35-year long arc of interpretation of the Second Vatican Council."
But there are clear differences. John Paul, born Karol Wojtyla, willingly put himself front and center in the church's cultural wars, using the papal pulpit to enter into the politics of morality in a way Francis has so far shied from emulating -- even though those wars are far from over.
"Pope Francis doesn't represent a man who fights over how the council was received or the conflict between the church's principles and the public sphere of morality," Melloni said. "He represents the fruit of the council in the sense of putting the Gospel in the center of Christian life."
That emphasis on spiritual life was obviously a core part of John Paul, who was known for his intense internal prayer life. But for John, it represented a break from popes past.
"For many centuries what was considered important to be a pope was to be a great sovereign, a great politician," Melloni said. John marked a turnabout in which the practicing life of a Christian "was again essential to being pope."
Like Francis, John grew up in a large, devout family where the women taught the young the simple piety of poor Catholics of the era. For John it was his mother, Marianna. For Francis his grandmother, Rosa. They both hailed from hearty northern Italian stock: Francis' grandparents moved to Argentina from Piedmont; Roncalli's family still hails from Bergamo.
John Paul's background was totally different, though he too came from a devout Catholic family. In Wadowice, Poland, he lost his mother when he was a child, his older brother when he was 14. By the time he was in his 20s, he was alone in the world after his father died.
Despite their different upbringings, all three arrived at the papacy with a visceral need to be around people.
John defined his life at the Vatican as that of a "bird in a gilded cage" and took every opportunity to escape. Francis opted to live at the Vatican hotel rather than the Apostolic Palace, saying his psychiatric health was in the balance.
John Paul rarely ate alone, often using the dinner table as both a place to talk over serious business or share good times with old friends from Poland.
"People, and yes even crowds, energized him," said Monsignor Slawomir Oder, who spearheaded John Paul's sainthood case.
Oder also acknowledged a darker side to John Paul. He had a temper and wasn't afraid of showing it. He was "hot blooded and emotional," Oder said, recalling how John Paul once berated a priest in his diocese for a misdeed and ordered him to hand over his driver's license.
John was known as the "good pope" -- affable, rotund, with big ears, warm eyes, a gentle smile and an excellent sense of humor. For those enthralled by Francis' papacy, it all sounds familiar though Francis himself has admitted he has an "authoritarian" streak.
The Rev. Robert Wister, a professor of church history at Seton Hall University, said the message to take home from Sunday's canonizations -- which might witness two living popes (Francis and emeritus Benedict XVI) honoring two dead ones -- is that there can be different approaches to the papacy, different types of popes, different applications of church teaching depending on the signs of the times.
"We're still one church," he said.