Christ’s words in John, about purging the Branch, have been applied to purgatory by a certain Vincent [of Beauvais; d. 1264], than whom no one ever twists the sense of Scripture more . . . The text in Maccabees  is left, and is quite plain. But that book does not make articles of faith, nor do the Fathers consider it an authority; the second book especially is several times rejected by Jerome.
 [Notes from this book] 2 Maccabees, 12:46, quoted supra, no. 163.
(Letter of Luther to Georg Spalatin, 7 November 1519; in 245-246; in Preserved Smith, translator and editor, Luther’s Correspondence and Other Contemporary Letters, Vol. I: 1507-1521, Philadelphia: The Lutheran Publication Society, 1913; from Enders, II, 224)
Note, then, that Luther does not deny that the teaching of purgatory is plain in 2 Maccabees; he only denies that it is authoritative. In other words, his argument is one from canonicity or the lack of that quality, rather than from theology or exegesis. This is confirmed by Luther’s best friend and successor Philip Melanchthon, in another letter contained in the same book (referred to in the footnote above):
After this they debated on the power of the Pope over the souls in purgatory, and Eck took a new tack and began to prove from the text in Maccabees that purgatory existed. Luther, following Jerome, denied that Maccabees was authoritative . . .
Lutheran biographer of Luther Julius Kostlin, gives the same report of the Leipzig Debate with Eck:
During the discussion of the subject of purgatory, a quotation was made from the Books of the Maccabees (2 Macc 12:45), in which prayer for the dead is commended. Luther did not wish to reject the teaching of the passage, but he pronounced it insufficient as evidence, since the books in question do not belong to the canon.
(Theology of Luther in Its Historical Development and Inner Harmony, Vol. 1, 1897, 317)
Luther maintained the same opinion in his 1521 treatise, An Argument in Defense of All the Articles of Dr. Martin Luther Wrongly Condemned in the Roman Bull:
THE THIRTY-SEVENTH ARTICLE
That there is a purgatory cannot be proved by those Scriptures which are authentic and trustworthy.
The existence of a purgatory I have never denied. I still hold that it exists, as I have written and admitted many times, though I have found no way of proving it incontrovertibly from Scripture or reason. I find in Scripture that Christ, Abraham, Jacob, Moses, Job, David, Hezekiah, and some others tasted hell in this life. This I think was purgatory, and it seems not beyond belief that some of the dead suffer in like manner. Tauler has much to say about it, and, in short, I myself have come to the conclusion that there is a purgatory, but I cannot force anybody else to come to the same result.
There is only one thing that I have criticized, namely, the way in which my opponents refer to purgatory passages in Scripture which are so inapplicable that it is shameful. . . .
But their use of the passage in II Macc. 12[:43], which tells how Judas Maceabeus sent money to Jerusalem for prayers to be offered for those who fell in battle, proves nothing, for that book is not among the books of Holy Scripture, and, as St. Jerome says, it is not found in a Hebrew version, the language in which all the books of the Old Testament are written. In other respects, too, this book deserves little authority, for it contradicts the first Book of Maccabees in its description of King Antiochus, and contains many other fables which destroy its credibility.
But even were the book authoritative, it would still be necessary in the case of so important an article that at least one passage out of the chief books [of the Bible] should support it, in order that every word might be established through the mouth of two or three witnesses. It must give rise to suspicion that in order to substantiate this doctrine no more than one passage could be discovered in the entire Bible; moreover this passage is in the least important and most despised book.
(in Luther’s Works, Vol. 32:95-96)John Huss (c. 1372-1415): one of the dissidents from the Catholic Church that Luther admired, who accepted purgatory but frowned upon prayers for the dead, was of the same opinion about purgatory in Maccabees:
We find no mention made of it except in the book of Maccabees, which is not placed by the Jews in the canon of the Old Testament.
(in Emile de Bonnechose, Letters of John Huss, Written During His Exile and Imprisonment, translated by Campbell Mackenzie, Edinburgh: William Whyte & Co., 1846, 196)
St. Augustine had utilized the same prooftext:
Possibly thy inquiry is satisfied by this my brief reply. But what other considerations move me, to which I think meet to answer, do thou for a short space attend. In the books of the Maccabees we read of sacrifice offered for the dead. Howbeit even if it were no where at all read in the Old Scriptures, not small is the authority, which in this usage is clear, of the whole Church, namely, that in the prayers of the priest which are offered to the Lord God at His altar, the Commendation of the dead hath also its place. But then, whether there be some profit accruing unto the soul of the dead from the place of its body, requires a more careful inquiry. And first, whether it make any difference in causing or increasing of misery after this life to the spirits of men if their bodies be not buried, this must be looked into, not in the light of opinion however commonly received, but rather of the holy writ of our religion.
(On Care to be Had For the Dead, 3; NPNF 1, Vol. III)
As for prayer for the dead apart from some notion of purgatory, Luther had not rejected it as late as 1528:
As for the dead, since Scripture gives us no information on the subject, I regard it as no sin to pray with free devotion in this or some similar fashion: ‘Dear God, if this soul is in a condition accessible to mercy, be thou gracious to it.’ And when this has been done once or twice, let it suffice. For vigils and requiem masses and yearly celebrations of requiems are useless, and merely the devil’s annual fair.
(Confession Concerning Christ’s Supper; in Luther’s Works, vol. 37, 369)
Nor did the Lutheran confessions:
Now, as regards the adversaries’ citing the Fathers concerning the offering for the dead, we know that the ancients speak of prayer for the dead, which we do not prohibit; but we disapprove of the application ex opere operato of the Lord’s Supper on behalf of the dead.
(Apology to the Augsburg Confession: article XXIV, 94; written by Philip Melanchthon)
The main reason Luther eventually rejected purgatory goes, I think, even deeper than whether it is explicitly supported in Scripture or not. It appears to be because he held to the heretical notion of soul sleep (that even John Calvin abominated). I’ve written a paper with an abundance of documentation, showing this.
It’s tough to believe in any semblance of a purgative process if one believes that the soul awaiting resurrection and final judgment is unconscious. Either one or the other belief has to go, since they are contraries. So Luther ditched purgatory (as usual, with inadequate reason: in this instance a heretical reason: one that is considered invalid not only by Catholics, but also the vast majority of Protestants). And that seems to have played a [key?] role in his rejection of the deuterocanonical books, which some biographers trace to this very debate with Eck in 1519, and Luther’s rejection of purgatory based on disputing the canonicity of 2 Maccabees.