1030 All who die in God's grace and friendship, but still imperfectly purified, are indeed assured of their eternal salvation; but after death they undergo purification, so as to achieve the holiness necessary to enter the joy of heaven.
1031 The Church gives the name Purgatory to this final purification of the elect, which is entirely different from the punishment of the damned. The Church formulated her doctrine of faith on Purgatory especially at the Councils of Florence and Trent. The tradition of the Church, by reference to certain texts of Scripture, speaks of a cleansing fire:
As for certain lesser faults, we must believe that, before the Final Judgment, there is a purifying fire. He who is truth says that whoever utters blasphemy against the Holy Spirit will be pardoned neither in this age nor in the age to come. From this sentence we understand that certain offenses can be forgiven in this age, but certain others in the age to come.1032 This teaching is also based on the practice of prayer for the dead, already mentioned in Sacred Scripture: "Therefore [Judas Maccabeus] made atonement for the dead, that they might be delivered from their sin." From the beginning the Church has honored the memory of the dead and offered prayers in suffrage for them, above all the Eucharistic sacrifice, so that, thus purified, they may attain the beatific vision of God. The Church also commends almsgiving, indulgences, and works of penance undertaken on behalf of the dead:
Let us help and commemorate them. If Job's sons were purified by their father's sacrifice, why would we doubt that our offerings for the dead bring them some consolation? Let us not hesitate to help those who have died and to offer our prayers for them.
Scripturally, we have to go through "the fire" as St. Paul tells us in his first letter to the Corinthians (1 Cor. 3: 11-20, New English) says and have our works tested. If they are like gold, we pass through unharmed. If they are like straw, they burn and we suffer. Exact quote from the New English version:
There can be no other foundation beyond that which is already laid; I mean Jesus Christ himself. If anyone builds on that foundation with gold, silver, and fine stone, or with wood, hay, and straw, the work that each man does will at last be brought to light; the day of judgement will expose it. For that day dawns in fire, and the fire will test the worth of each man’s work. If a man’s building stands, he will be rewarded; if it burns, he will have to bear the loss; and yet he will escape with his life, as one might from a fire.
For other foundation can no man lay than that is laid, which is Jesus Christ. Now if any man build upon this foundation gold, silver, precious stones, wood, hay, stubble; Every man's work shall be made manifest: for the day shall declare it, because it shall be revealed by fire; and the fire shall try every man's work of what sort it is. If any man's work abide which he hath built thereupon, he shall receive a reward. If any man's work shall be burned, he shall suffer loss: but he himself shall be saved; yet so as by fire.