The short answer: We are justified (counted righteous in God’s sight) by faith alone, but the faith that justifies is never alone.
Justified by faith alone…: We are justified by faith apart from works of the law (Rom.3:28). God counts us as righteous because he credits the very righteousness of Christ tous (Phil. 3:9, Rom. 5:17). All this happens by faith alone, apart from any good works we do (Rom. 4:4-5).
…But the faith that justifies is never alone: All those who genuinely believe in Christ do so only because they have been given new life by the Holy Spirit (John 3:1-8). They’ve been given a new heart that loves God and delights to obey God’s law (Ezek. 36:26-27; Jer. 31:33; Rom. 7:22). And so their lives are characterized by increasing good works and increasing conformity to God’s holy character (2 Pet. 1:8; Eph. 2:10; 2 Cor. 3:18).
Two things to keep in mind: So when the Bible speaks of God judging all people on the last day “according to their works” (2 Rom. 2:6), two things are important to keep in mind.
First, All who believe in Christ are counted righteous in God’s sight and are utterly safe from the wrath of God (Rom. 4:4-8, 5:9-11; 1 Thess. 1:10).
Second, All those who believe in Christ will live lives that are characterized by righteous deeds (Eph. 2:10). So when God judges us “according to our works” he will not be weighing us in the scales of justice and finding that our works measure up to his perfect holiness (they never would!), but rather pronouncing a righteous verdict over us that, while it is on the basis of Christ’s righteousness alone, is consistent with the righteousness our lives have displayed. On the last day our works will either show the validity or falsehood of our faith (Matt. 7:21-23).