At first glance, it would seem the bible contradicts itself. Paul said in Romans 4:2 (NAS), "For if Abraham was justified by works, he has something to boast about, but not before God."
We have to look at the verse in the context of the scripture in the book of James, and in context of the whole of scripture. In James, if we read further, we begin to see what James was speaking about.
James 2:22-24 (NAS)
"22 You see that faith was working with his works, and as a result of the works, faith was perfected; 23 and the Scripture was fulfilled which says, 'AND ABRAHAM BELIEVED GOD, AND IT WAS RECKONED TO HIM AS RIGHTEOUSNESS,' and he was called the friend of God. 24 You see that a man is justified by works and not by faith alone."
The point James was trying to establish is that faith without works is an empty faith. It is not a true faith in a true God.
Think of this...we are to have faith that Christ can save us and work in us. If Jesus is truly working inside of us, then the Spirit in us should produce fruit. We should produce fruit in the way of works. The works we do, then, are not our own, they are not our works, but are the works of God. God is working in us, so that our works become His works.
James is trying to say that we need to produce good works as a result of our faith being true.
Paul also emphasized this in Ephesians 2:10 (NAS), "For we are His workmanship, created in Christ Jesus for good works, which God prepared beforehand so that we would walk in them." And in Colossians 1:10, Paul said, "...bearing fruit in every good work."
So you see, the works are not our own, but instead are fruit. In the above scripture, when Abraham was justified by works, it was not his "own" works, but the "works" of God in him. James tries to establish this point by following the above scripture with a quote from the old testament saying that the righteous works of Abraham were credited by way of believing.
This is such an important thing because Jesus said plainly...
Matthew 3:10(NAS) "The axe is already laid at the root of the trees; therefore every tree that does not bear good fruit is cut down and thrown into the fire."
At first, you might think that we need to rush out and do a bunch of good works. However, we cannot do anything on our own. Our works are nothing unless they are the fruit of God. In the book of John, Jesus was quoted as saying, (John 15:5,6 - NAS) "I am the vine, you are the branches; he who abides in Me and I in him, he bears much fruit, for apart from Me you can do nothing. 6 If anyone does not abide in Me, he is thrown away as a branch and dries up; and they gather them, and cast them into the fire and they are burned."
And so, "working" or "works" are important, but they are not achieved by "working" by our own accord. Our works are only good when we abide in Christ. When we truly abide in Christ, and Christ in us, we are made one with Christ. When this happens, we produce fruit naturally. We do good works because we are one with Christ. Often times, these good works are not even recognizable by us, but only by God who knows all things and sees all things. We often judge by what we can see, but God judges differently.
And so, the important thing for us is to allow God to work in us. How do we do that?
Luke 9:23(NAS) "And He was saying to them all, 'If anyone wishes to come after Me, he must deny himself, and take up his cross daily and follow Me.'"
We need to die daily to the world and self, and give ourselves to Jesus. Every day, we need to give ourselves to Jesus and ask Him to come into us.
In John 6, Jesus said He was the bread of Heaven. In the model prayer, Jesus said we should ask for our daily bread. Everyday, we need to ask for Jesus and accept Him into our heart. We should confess our sins before God, ask Jesus to remove them, and then abide in Christ. When this happens, our faith becomes true. When our faith is true, it produces good works.
Otherwise, according to James, if we are not producing works, then our faith is dead (James 2:26). Our faith should produce works.
As a side note, though this is true, this is not a means by which we can judge other people. We have no place saying who is saved and who is not. Just because a person is not producing any fruit, we cannot say, "You are not a Christian." We can, however, point out that they have no works, or that their works conflict with the bible. In this, we should always encourage others in love, with the soul purpose of strengthening their faith. However, our goal should never be to use force. Christ never used force, but always gave Himself unto others. We should do no less.
Hope this helps,