When and how did Martin Luther arrive at the justification by faith teaching? Was it something that he came up with as a result of his stance against the indulgences and later against the Pope, or did he arrive at this teaching even prior to those events?
First to understand the background to the story that Luther recalls, Luther used to hate Romans 1:17. He struggled with this verse in particular, and the phrase 'God's righteousness' in particular, because he always read it in the sense which it was preached by the Catholic theologians at the time. At that time this verse was understood as the "formal or active righteousness" with which "God is righteous and punishes the unrighteous sinner." In other words, Luther while believing in God and having some faith in Christ struggled with Romans 1:17 before his 'confidence burst' and his faith began to posses him more violently. This is why Romans 1:17 is brought up in his recollections but actually plays little part in his explaining his actual beliefs later on. This he did, regarding justification by faith, most fully in his lectures on Galatians, although Romans as a whole still held an important place as well.
His experience or turning point in breaking through on his understanding of Romans 1:17 is referred to as his 'Tower Experience' because it occurred in the tower of the Black Cloister in Wittenberg (later Luther’s home) at an undetermined date between 1508 and 1518.
Luther, before overcoming his doubts about Romans 1:17, used to think 'God's righteousness' in the gospel 'was revealed', not in giving perfect righteousness freely to sinners forever apart from the fact they were sinners, but in punishing sinners and rewarding the righteous. Luther, originally as a monk, viewed the gospel as an extension of the law, not a way to find freedom from its curse. Only later did he discover that a person is saved by faith, without works of the law entering into the equation. He always saw that faith produced many works, but not allowing those works to take part in the subject of justification, where we 'passively receive' righteousness as a gift, apart from our own merit, was something he learned later on. I think the Romans 1:17 'tower experience' that he had was probably during his lectures on Romans which began in the year 1516.
Before this experience He says he had faith but it was not clear yet:
For a long time I went astray [in the monastery] and didn’t know what I was about. To be sure, I knew something, but I didn’t know what it was until I came to the text in Romans 1 [:17], ‘He who through faith is righteous shall live.’ That text helped me. There I saw what righteousness Paul was talking about.82 Earlier in the text I read ‘righteousness.’ I related the abstract [‘righteousness’] with the concrete [‘the righteous One’] and became sure of my cause. I learned to distinguish between the righteousness of the law and the righteousness of the gospel. I lacked nothing before this except that I made no distinction between the law and the gospel. I regarded both as the same thing and held that there was no difference between Christ and Moses except the times in which they lived and their degrees of perfection. But when I discovered the proper distinction—namely, that the law is one thing and the gospel is another—I made myself free.” (Luther's Works, Volume 54, P442).
In 1545, he describes his own experience at greater length. He seems to take a longer view if it, like a growing faith and struggle that begins by referring to his days as a monk, his weak faith in his earlier days as a Biblical Professor and finally his overwhelming sense of what Romans 1:17 really meant. He recalled these experiences when describing the events that occurred in the year 1519 when he got into trouble with the Pope. To understand at what point in his thinking 1519 occurs it is helpful to know that Luther first lectured on Romans at around the year 1516, he also lectured a preliminary version of Galatians and Hebrews shortly after this time. However, he did not lecture on Galatians, formally, in the format in which they were published, until around 1531. It took around 16 years for his faith to really explode in the form of Galatians, long after he had kicked the hornets nest in Rome.
In fact, this gripping realization of justification by faith made him revisit his old lectures and begin to rewrite them as early as 1519. It is just before this time that he made his breakthrough in the 'tower experience'. Removing his misunderstanding of that verse, his faith seems to have broke into a full confidence and the verse that used to trouble him became an anchor that symbolized his overwhelming conviction that began slowly years before and grew more and more years later. Here we find he began to revise his work on the Psalms in 1519 and his breakthrough over his doubts about Romans Chapter 1:17 that had 'stood in his way' until this point.
Meanwhile, I had already during that year returned to interpret the Psalter anew. I had confidence in the fact that I was more skilful, after I had lectured in the university on St. Paul’s epistles to the Romans, to the Galatians, and the one to the Hebrews. I had indeed been captivated with an extraordinary ardor for understanding Paul in the Epistle to the Romans. But up till then it was not the cold blood about the heart,but a single word in Chapter 1[:17], “In it the righteousness of God is revealed,” that had stood in my way. For I hated that word “righteousness of God,” which, according to the use and custom of all the teachers, I had been taught to understand philosophically regarding the formal or active righteousness, as they called it, with which God is righteous and punishes the unrighteous sinner.
Though I lived as a monk without reproach, I felt that I was a sinner before God with an extremely disturbed conscience. I could not believe that he was placated by my satisfaction. I did not love, yes, I hated the righteous God who punishes sinners, and secretly, if not blasphemously, certainly murmuring greatly, I was angry with God, and said, “As if, indeed, it is not enough, that miserable sinners, eternally lost through original sin, are crushed by every kind of calamity by the law of the decalogue, without having God add pain to pain by the gospel and also by the gospel threatening us with his righteousness and wrath!” Thus I raged with a fierce and troubled conscience. Nevertheless, I beat importunately upon Paul at that place, most ardently desiring to know what St. Paul wanted. (Luther's Works, Volume 34, P336-337).
At last, by the mercy of God, meditating day and night, I gave heed to the context of the words, namely, “In it the righteousness of God is revealed, as it is written, ‘He who through faith is righteous shall live.’ ” There I began to understand that the righteousness of God is that by which the righteous lives by a gift of God, namely by faith. And this is the meaning: the righteousness of God is revealed by the gospel, namely, the passive righteousness with which merciful God justifies us by faith, as it is written, “He who through faith is righteous shall live.” Here I felt that I was altogether born again and had entered paradise itself through open gates. There a totally other face of the entire Scripture showed itself to me. Thereupon I ran through the Scriptures from memory. I also found in other terms an analogy, as, the work of God, that is, what God does in us, the power of God, with which he makes us strong, the wisdom of God, with which he makes us wise, the strength of God, the salvation of God, the glory of God. (Luther's Works, Volume 34, P336-337).
He continues to explain the effects of his experience about Romans 1:17 and how he later found additional support through Augustine. He already had his doctorate in theology in October 19, 1512 and may seem strange that he did not encounter Augustine's work on the subject until years later, but it is a very specific one which Luther mentions, called 'The Spirit and the Letter.'
And I extolled my sweetest word with a love as great as the hatred with which I had before hated the word “righteousness of God.” Thus that place in Paul was for me truly the gate to paradise. Later I read Augustine’s The Spirit and the Letter, where contrary to hope I found that he, too, interpreted God’s righteousness in a similar way, as the righteousness with which God clothes us when he justifies us. Although this was heretofore said imperfectly and he did not explain all things concerning imputation clearly, it nevertheless was pleasing that God’s righteousness with which we are justified was taught. Armed more fully with these thoughts, I began a second time to interpret the Psalter. And the work would have grown into a large commentary, if I had not again been compelled to leave the work begun, because Emperor Charles V in the following year convened the diet at Worms.49. (Luther's Works, Volume 34, P336-337).
The truth is although Romans was the place where he made his initial breakthrough it was not the place where his faith finally rested on. For this we must turn to Galatians. In fact Luther hardly has any comments at all under Chapter 1:7 in his works on Romans, but in every verse of Galatians, Luther uses as one more opportunity to pound and pound away at the doctrine that changed his life forever. No bible commentary on any book in the Bible since can pretend in any way to have had the same impact on the world.
As a result of the revolutionary changes in Luther and his dramatic growing faith is there is a problem with Luther's Works in that he had to re-write many things and where the need was not urgent he seems to have left them as they were. Romans is a little thin on doctrine compared to Galatians, as he wrote it years before, it is also was not needing much revision, so Luther probably found most of it still acceptable to him even under his enlarged views years later.
His commentary on Galatians was when he was crystal clear in 1531 and he does not seem to have had enough time to fully rewrite everything before to measure up to his final stage of assurance and knowledge. Therefore regarding the timing of his understanding of the doctrine that in many ways resulted in the Protestant church, I would say that his faith was crystallized around 1517 with Romans and from there it grew until it exploded with Galatians in 1531. He seems to have hung his faith not on Romans at all by this point. Galatians was his eventual favorite work and the essential Luther.
For anyone interested in reading Luther, He wrote his works on Genesis after Galatians so they are not in any need up of updating at all and are a good place to start after Galatians. Some of his earlier works however must be viewed and even possibly corrected by comparing them to Galatians.
After all his years Luther clearly favored his writing on Galatians above all else. I am sure he would have instantly agreed to the burning of all his books if he might keep his work on Galatians. It is here where you find Luther's views in the doctrine of salvation by faith, apart from works. One can't understand Luther at all without reading it. Anyone who has read it will understand why. I challenge anyone interested in Luther to read his work on Galatians in order to begin to understand him.
Luther described his relation to the epistle in more vivid terms. “The Epistle to the Galatians,” he once said at table, “is my epistle, to which I am betrothed. It is my Katie von Bora.” (Luther's Works, Volume 26, Introduction)
According to Luther's own testimony, it was after an in depth study of Romans. Romans 1:17 in particular (often called Paul's thesis statement for the book of Romans) says:
For in it the righteousness of God is revealed from faith for faith, as it is written, “The righteous shall live by faith."
That last line (from Habakkuk) convinced Luther that no work of man, and hence no religious decree of the Church, trumped Faith.