Galatians 3:24

24 Accordingly, the Torah functioned as a custodian until the Messiah came, so that we might be declared righteous on the ground of trusting and being faithful.

Galatians 3:24 In-Context

22 But instead, the Tanakh shuts up everything under sin; so that what had been promised might be given, on the basis of Yeshua the Messiah's trusting faithfulness, to those who continue to be trustingly faithful.
23 Now before the time for this trusting faithfulness came, we were imprisoned in subjection to the system which results from perverting the Torah into legalism, kept under guard until this yet-to-come trusting faithfulness would be revealed.
24 Accordingly, the Torah functioned as a custodian until the Messiah came, so that we might be declared righteous on the ground of trusting and being faithful.
25 But now that the time for this trusting faithfulness has come, we are no longer under a custodian.
26 For in union with the Messiah, you are all children of God through this trusting faithfulness;
Complete Jewish Bible Copyright 1998 by David H. Stern. Published by Jewish New Testament Publications, Inc. All rights reserved. Used by permission.