The Church doctrine about Purgatory is based on the Bible, when it is interpreted in the right way:
The text from Maccabees II 12, 43-46 supposes a purification after death.
From the Holy Scriptures
(Judah Maccabeus) made among his soldiers a collection… so that it was offered for him a sacrifice for sins… because… they believed firmly in a precious reward for those who die in God’s Grace… he offered this sacrifice for the dead; so that they could be pardoned for their sins.
In the same way the words of our Lord:
Anyone who speaks a word against the Son of Man will be forgiven, but anyone who speaks against the Holy Spirit will not be forgiven, either in this age or in the age to come.
As you are going with your adversary to the magistrate, try hard to be reconciled to him on the way, or he may drag you off to the judge, and the judge turn you over to the officer, and the officer throw you into prison. I tell you, you will not get out until you have paid the last penny.
In this abstracts Jesus refers to a temporary punishment that could not be the Hell nor Heaven.
It is possible to reach a similar conclusion in Saint Paul’s letter:
For no one an lay any foundation other than the one already laid, which is Jesus Christ. If any man builds on this foundation using gold, silver, costly stones, wood, hay or straw, his work will be shown for what it is, because the Day will bring it to light. It will be revealed with fire, and the fire will test the quality of each man’s work.
(1 Corinthians 3,11-13).
In the way that it has a fire after death that, in a different way than Hell, it is temporary. The soul who will pass trough it, will be saved. This state of purification is called "Purgatory".
Now if there is no resurrection, what will those do who are baptized for the dead? If the dead are not raised at all, why are people baptized for them? (1 Corinthians 15:29).
The word "baptism" is used here like a metaphor in order to express suffering and contrition;
- "You don’t know what you are asking," Jesus said. "Can you drink the cup I drink or be baptized with the baptism I am baptized with?" "We can," they answered. Jesus said to them, "You will drink the cup I drink and be baptized with the baptism I am baptized with".
(Mark 10, 39-40).
- John answered them, "I baptize you with water. But one more powerful than I will come, the thongs of whose sandals I am not worthy to untie. He will baptize you with the Holy Spirit and fire.
(Luke 3, 16).