Who first explicitly understood "works of the law" in Galatians 3:10 as referring to only the ritual law, and not the Mosaic law generally? One of the key verses used to defend the Protestant doctrine of justification by faith alone is Galatians 3:10:


  For all who rely on works of the law are under a curse; for it is written, “Cursed be everyone who does not abide by all things written in the Book of the Law, and do them.” [ESV]


Proponents of "faith + works" justification often argue that "works of the law" in this verse actually refers to the ritual or ceremonial law, not to the entire Mosaic law, in spite of the word "all" in Paul's quotation.

J. Gresham Machen critiques one such opponent of sola fide and calls his commentary on Galatians "medieval," saying that this sort of exegesis is "a return to the religion of the Middle Ages" (Christianity and Liberalism, 121).  In at least one sense he's right, since this was the typical understanding prior to the Reformation.  But his implication, perhaps, is that this view was not held in the early church. 

So my question is: when do we first see an explicit claim that "works of the law" in Galatians 3:10 refers not to the Mosaic law generally but only to a subset of it (i.e., ritual/ceremonial law, excluding moral law)? Is Machen's implication correct, or does such analysis originate in the early church?

Related: In the NPP, if Paul's “works of the law” are only circumcision and diet, how is Galatians 3:10 interpreted?
Marius Victorinus
The earliest clear instance of this interpretation of this verse that I've found appears to be in Marius Victorinus's commentary on Galatians (written mid-4th century).  He describes the &quot;works which belong to Christianity&quot; as:

those works which the apostle frequently commands (and also what has been commanded to him: let us be mindful of the poor) and the additional precepts for living which are included in this apostle's writings.  Each one of these works is commanded by the apostle to be fulfilled by every Christian.

Against these moral instructions he contrasts the &quot;works of the Law&quot;:

The works of the Law, then, are something else: religious observances, obviously, offerings of a lamb (although the Passover has now been fulfilled through Christ); and there are further works which they do as well, pertaining to circumcision and foods to be observed or prepared. (source, emphasis in original)

Sadly, a large gap appears in Victorinus's commentary immediately after this section, so we don't know how he develops the theme.  A modern editor, Stephen Cooper, argues that he is pointing out &quot;that there are other works whose obligatory performance by Christians do not bring a curse,&quot; not that justification comes from such works.  Even so, the distinction is made – Victorinus makes it clear that he sees at least some aspects of the moral law as not in view in Galatians 3:10.
Origen
An earlier example of this view is found in the writings of Origen (early to middle third century).  Unfortunately, his commentaries on Galatians have been lost, but it seems likely that something like the following would have been included in them.  In his commentary on Romans, 8.7.6, he writes:

One should know that the works that Paul repudiates and frequently criticizes are not the works of righteousness that are commanded in the law, but those in which those who keep the law according to the flesh boast; i.e., the circumcision of the flesh, the sacrificial rituals, the observance of Sabbaths or new moon festivals. (source)

So we see that this is certainly not merely a &quot;medieval&quot; interpretation; at least some in the early church held to it as well.