In his 1863 encyclical letter to the bishops of Italy, Pope Pius IX wrote: "Well known is the Catholic teaching that no one can be saved outside the Catholic Church. Eternal salvation cannot be obtained by those who oppose the authority and statements of the same Church and are stubbornly separated from the unity of the Church and also from the successor of Peter, the Roman Pontiff".
In the same letter, he said: "There are, of course, those who are struggling with invincible ignorance about our most holy religion. Sincerely observing the natural law and its precepts inscribed by God on all hearts and ready to obey God, they live honest lives and are able to attain eternal life by the efficacious virtue of divine light and grace since God who clearly beholds, searches, and knows the minds, souls, thoughts, and habits of all men, because of His great goodness and mercy, will by no means suffer anyone to be punished with eternal torment who has not the guilt of deliberate sin."
He added: "God forbid that the children of the Catholic Church should even in any way be unfriendly to those who are not at all united to us by the same bonds of faith and love. On the contrary, let them be eager always to attend to their needs with all the kind services of Christian charity, whether they are poor or sick or suffering any other kind of visitation.
First of all, let them rescue them from the darkness of the errors into which they have unhappily fallen and strive to guide them back to Catholic truth and to their most loving Mother who is ever holding out her maternal arms to receive them lovingly back into her fold.
Thus, firmly founded in faith, hope, and charity and fruitful in every good work, they will gain eternal salvation."
The 2000 declaration Dominus Iesus of the Congregation for the Doctrine of the Faith states that "it must be firmly believed that the Church, a pilgrim now on earth, is necessary for salvation: the one Christ is the mediator and the way of salvation; he is present to us in his body which is the Church. He himself explicitly asserted the necessity of faith and baptism (cf. Mk 16:16; Jn 3:5), and thereby affirmed at the same time the necessity of the Church which men enter through baptism as through a door."
The Church does, however, in believing baptism is necessary for salvation (John 3:5) believe that one can enter the Church through baptism of desire, either an explicit or implicit desire. Regarding an implicit desire, the Church has always used the principal that if one is innocent by ignorance to the truth, then they are not guilty of any sin and will not be held guilty for what they, through no fault of their own, did not know.
In regard to explicit desire, the Catechism of the Catholic Church teaches, "For catechumens [those instructed in the Catholic faith who are preparing to be baptised into the Catholic Church] who die before their Baptism, their explicit desire to receive it, together with repentance for their sins, and charity, assures them the salvation that they were not able to receive through the sacrament" (CCC 1259).
In one of the preperatory schemas for the [[Second Vatican Council|Second Ecumenical Council of the Vatican], this was written regarding baptism of desire: "As for those ordered by desire towards the Church, these include not only catechumens, who, moved by the Spirit, consciously and explicitly desire to enter the Church, but also those who, even if not knowing that the Catholic Church is the true and sole Church of Christ, still, by God's grace, implicitly and unknowingly desire the equivalent, either because they sincerely will what Christ himself wills or because, though ignorant of Christ, they sincerely desire to fulfill the will of God their Creator. The gifts of heavenly grace will never be wanting to those who sincerely desire and ask to be renewed by the divine light".
This preparatory document was revised to become the Constitution Lumen Gentium, which said: "Those also can attain to salvation who through no fault of their own do not know the Gospel of Christ or His Church, yet sincerely seek God and moved by grace strive by their deeds to do His will as it is known to them through the dictates of conscience. Nor does Divine Providence deny the helps necessary for salvation to those who, without blame on their part, have not yet arrived at an explicit knowledge of God and with His grace strive to live a good life. Whatever good or truth is found amongst them is looked upon by the Church as a preparation for the Gospel. She knows that it is given by Him who enlightens all men so that they may finally have life.
But often men, deceived by the Evil One, have become vain in their reasonings and have exchanged the truth of God for a lie, serving the creature rather than the Creator. Or some there are who, living and dying in this world without God, are exposed to final despair. Wherefore to promote the glory of God and procure the salvation of all of these, and mindful of the command of the Lord, "Preach the Gospel to every creature", the Church fosters the missions with care and attention."
This is why the doctrine that there is no salvation outside the Catholic Church is so essential to Catholic doctrine, it is inter-entwined in the doctrine of the one true Church.