The Apostle says (2 Corinthians 3:6): "The letter killeth": which, according to Augustine (De Spir. et Lit. xiv), refers even to the moral precepts. Therefore the moral precepts did not cause justice. [ST I-II, Q100, A12; emphasis added]
That's the summary, but on this subject St. Thomas is careful to make distinctions. There are different senses in which the words "just," "justice," "justify," and "justification" might be used, and he would have us be clear as to what exactly he has in view.
Just as "healthy" is said properly and first of that which is possessed of health, and secondarily of that which is a sign or a safeguard of health; so justification means first and properly the causing of justice; while secondarily and improperly, as it were, it may denote a sign of justice or a disposition thereto. If justice be taken in the last two ways, it is evident that it was conferred by the precepts of the Law; in so far, to wit, as they disposed men to the justifying grace of Christ, which they also signified, because as Augustine says (Contra Faust. xxii, 24), "even the life of that people foretold and foreshadowed Christ." [ST, op. cit.]Improperly speaking, we may say that the Law acted as a sign of justice: where it is fulfilled, justice is being done. Similarly it may indicate an inclination toward justice in the same way. But neither of these senses are the primary, proper meaning of justification, which he defines as "the causing of justice."
Even when speaking of the proper sense of the word, though, still more distinctions must be made.
But if we speak of justification properly so called, then we must notice that it can be considered as in the habit or as in the act: so that accordingly justification may be taken in two ways. First, according as man is made just, by becoming possessed of the habit of justice: secondly, according as he does works of justice, so that in this sense justification is nothing else than the execution of justice. [ibid.]The important thing to see here is that he distinguishes justification as a virtue (which, as we shall see, is the main point) from the doing of justice. To do just works is not the same as to be justified before God.
Once again, however, we see that yet another distinction must be made. For justice as a moral virtue may be distinguished as an acquired or infused habit.
Now justice, like the other virtues, may denote either the acquired or the infused virtue, as is clear from what has been stated (63, 4). The acquired virtue is caused by works; but the infused virtue is caused by God Himself through His grace. The latter is true justice, of which we are speaking now, and in this respect of which a man is said to be just before God, according to Romans 4:2: "If Abraham were justified by works, he hath whereof to glory, but not before God." Hence this justice could not be caused by moral precepts, which are about human actions: wherefore the moral precepts could not justify man by causing justice. [ibid.; emphasis added]So we see that for St. Thomas, the justice by which we are justified before God is something that God gives us; it "could not be caused by moral precepts, which are about human actions."
It's probably worth taking a glance at the earlier part of the Summa that Aquinas references in that section: I-II, Q63, A4. The article asks the question, "Whether virtue by habituation belongs to the same species as infused virtue?" Is there any difference between virtues we acquire by force of habit and those that God infuses into us? St. Thomas affirms that there is:
Any change introduced into the difference expressed in a definition involves a difference of species. But the definition of infused virtue contains the words, "which God works in us without us," as stated above (Question 55, Article 4). Therefore acquired virtue, to which these words cannot apply, is not of the same species as infused virtue.Hence the justification in view here must be given by God, and cannot be acquired in any other way. Consequently we see that those who accuse Catholics of believing in a works-based salvation are badly misinformed.