They call this saying the heart of Protestant Reformation, the 5 Solas.
Now, originally there were only 3:
The saying is a conflation of Eph 2, NIV:
8 For it is by grace you have been saved, through faith—and this is not from yourselves, it is the gift of God— 9 not by works, so that no one can boast.
But in order to understand what Paul meant we need to break this down in 2 parts:
The answer will also properly define what Paul meant by salvation by grace.
1. The faith of Jesus.
In Rom 3.22 Paul writes that we are made right in the sight of God through faith in Jesus or by the faith of Jesus.
This of course is not to deny the biblical teaching that believers should also have faith in Christ.
Then in Rom 10:17 Paul defines faith as hearing the word or the message of Christ, i.e., the gospel Jesus preached.
These verses are leading you to ask one very important question:
What word/message did Jesus preach?
The answer will define for us Jesus own belief, the gospel of Jesus.
Like the OT prophets before him like Isaiah [9.7] and Daniel [2.44], Jesus believed that one day the God of heaven would set up a kingdom different from all the others because it will bring never-ending peace and real justice.
But this will only happen when the Son, along with the saints of the Most High God, finally receive the kingdom: Dan 7:18.
And only then will Christians rule/govern the world: 1Cor 6.2.
Jesus himself makes this promise to his Apostles in Luke 12.32:
“For it is your Father’s good pleasure, to give you the Kingdom”!
This is the reason why Jesus says he was sent/commissioned by God in the first place: Luke 4.43
And this is supposed to be the purpose statement for the church, aka the Great Commission command by Jesus in Mat 28:19-20.
2. Which works?
Now we would all agree that the Christian walk of faith takes real effort, i.e., real works on the part of the believer.
After all, Jesus did say we must “strive to enter” the Kingdom of God (Lk. 13:24).
And Paul later commands to continue to work out your salvation with fear and trembling (Phil. 2:12).
We also know that many times Paul uses the word works in reference to the Law of Moses:
Therefore no one will be justified in His sight by works of the law. Rom 3.20
And contrasts the Law of Moses with the faith of Jesus:
Knowing that a man is not justified by works of law, but through the faith of Jesus Christ. Gal 2:16.
So when we turn back to Ephesians 2 we understand that no Christian can be made right by the works of the Old Law of Moses.
For we are now God’s workmanship, created in Christ Jesus for good works, Eph 2.10.
Eph 2.14: Christ has made peace between Jews and Gentiles, and he has united us by breaking down the wall of hatred that separated us.
Eph 2.15: He accomplished this, Paul goes on to explain, by setting aside in his flesh the law with its commands and regulations.
So like Paul and the father of the faith himself Abraham, we are to be faithful workmen of God.
James 2 summarizes this nicely when he explains that the faith of Abraham, along with his works, made his faith complete.
In other words, it’s not either/or but both/and.