"Despite many human failings, the church was the alternative to the destructive ideology of the brown rulers; in the inferno that had swallowed up the powerful, she had stood firm with a force coming to her from eternity," he wrote.
Ratzinger entered a seminary in 1939, following in the footsteps of his older brother Georg, who also became a priest. But in 1943 he was conscripted along with his entire class into the Nazi antiaircraft corps and sent to defend a factory that made aircraft engines. He told Time magazine in 1993 that a badly infected finger prevented him from ever firing a shot.
He was subsequently drafted into forced labor, then into an army unit. In the final months of the war, Ratzinger deserted from his unit. He later spent several weeks in an American POW camp before making his way back home to the town of Traunstein and reentering the seminary.
In 1951 he was ordained a priest, along with his brother. He went on to earn a doctorate in theology at the University of Munich, where he developed a love of patristics, the study of the key thinkers in the first eight centuries of the church.
By the 1960s, patristics had gone out of style. The leading lights in Catholic theology were grappling with modernism, and Ratzinger was soon embroiled in a watershed event in his life and the life of the entire church: the Second Vatican Council.
The council, first convened by Pope John XXIII, brought nearly 3,000 bishops and their expert advisers, including many theologians, to Rome for a series of meetings from 1962 to 1965 that resulted in 16 major documents and caused a revolution in Catholic thinking and practice.
Most famously, Vatican II cleared the way for the Mass to be said not just in Latin but also in the modern languages spoken by Catholics around the world. But alongside the liturgical reforms came even more far-reaching changes in other areas. The council's "Constitution on Divine Revelation" accepted a critical approach to the Bible. Its "Declaration on Religious Freedom" accepted the idea that governments should be neutral toward religion. Its "Decree on Ecumenism" endorsed the search for unity with other Christians, abandoning centuries of hostility toward Protestants.
Yet many of these documents created as many questions as they answered -- questions that were still being debated by cardinals as they went into this week's conclave, such as how far Catholics should go toward accepting other faiths as paths to God, and how much power the pope should share with bishops and their national associations.
Ratzinger attended the council as an adviser to Cardinal Joseph Frings, an ecclesial moderate who emerged as a leader of the progressive wing in the council's debates. The future pope gained a reputation as a reformer at the time, serving on the board of the reformist journal Concilium.
In 1968, many of the reformers, including Ratzinger, were shaken by two events: the anti-establishment and antiwar student riots that convulsed Europe, and the sharp dissent that greeted Pope Paul VI's encyclical against contraception, Humanae Vitae. By 1972, Ratzinger and several other leading theologians left Concilium to form a rival journal, Communio, with a more traditional line.
Dennis Doyle, a historian of the church at the University of Dayton in Ohio, said there is still debate over whether Ratzinger's views changed, or whether he remained constant and the world changed around him. What is clear, he said, is that Ratzinger "has always been quite happy with the results of the council in terms of basic documents" but felt that the implementation was becoming "too political, too focused on immanence -- God's presence in this world -- and not focused enough on transcendence, God's invitation to man for communion in eternity."
In a sign of his relative conservatism and rising discontent, Ratzinger left a prestigious post at Germany's University of Teubingen to help launch a new, more orthodox Catholic university at Regensburg in his native Bavaria. His academic career effectively ended, however, when he was named archbishop of Munich and Freising and elevated to cardinal in 1977.
Ratzinger first met Karol Wojtyla, the future John Paul II, the following year, when both came to Rome to attend the conclave to replace Paul VI. They had crossed paths at the Second Vatican Council and had read each other's books, but when they met in person, there was "spontaneous sympathy," Ratzinger told John Paul's biographer, George Weigel.
Once he became pope, John Paul called Ratzinger to Rome to head the Congregation for the Doctrine of the Faith, the institutional successor to the Inquisition. Though it has a staff of only about 40, it wields enormous influence through its ability to censure theologians and vet documents from other Vatican departments for doctrinal orthodoxy.
By all accounts, Ratzinger wielded those tools heavily. With his antagonism to nationalism, he helped John Paul keep a tight rein on national bishops' conferences. With his insistence on the supremacy of Catholicism over other faiths, he wrote a letter, Dominus Iesus, that declared that all other religions were "defective" by comparison. And with his belief in holding fast to absolute truth, he oversaw the disciplining of theologians who questioned the church's doctrine on papal infallibility as well as its bans on contraception and ordination of women as priests.
Some of the new pope's ardent admirers believe that he is not, by nature, rigid.
"He has been misrepresented because of the role he has had as prefect of the Congregation of the Doctrine of the Faith. Anyone who has that job is always disliked," said the Rev. Thomas Williams, dean of theology at the Pontifical University Regina Apostolarum in Rome.
But as pope, he will face a church that is still deeply divided on many issues and pulled in many directions, from demands for a tough stand against the impact of economic globalization in Latin America, to calls for the empowerment of women and the laity in the United States, to open violation of the ban on condom use by bishops concerned about HIV/AIDS in Africa. Given his lifelong belief in constancy, it is hard to see how Benedict XVI could waver now.
Special correspondents Sarah Delaney and William Magnuson contributed to this report.