Rather than just answering that question up front, why don't we take a look at what the Bible says about this question. Depending on what theological background you come from, you may have a different answer. However, there seems to be only one answer that fits with biblical, orthodox Christianity.
Two main passages will be looked at to answer this question. One passage is used to favor the concept of what is called "works-based righteousness." The other is often used to refute the idea of works as it relates to salvation. In the end, what we get out of this is a couple of passages where one seems to indicate that works are required, another that seems to say they're not and the concept that people will claim that the Bible contradicts itself.
The first passage we will look at is going to be from James 2. This particular passage is somewhat lengthy, but I think it is important to look at the passage in its entirety.
14 What use is it, my brethren, if someone says he has faith but he has no works ? Can that faith save him? 15 If a brother or sister is without clothing and in need of daily food, 16 and one of you says to them, "Go in peace, be warmed and be filled," and yet you do not give them what is necessary for their body, what use is that? 17 Even so faith, if it has no works, is dead, being by itself. 18 But someone may well say, "You have faith and I have works ; show me your faith without the works, and I will show you my faith by my works." 19 You believe that God is one. You do well ; the demons also believe, and shudder. 20 But are you willing to recognize, you foolish fellow, that faith without works is useless ? 21 Was not Abraham our father justified by works when he offered up Isaac his son on the altar ? 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. 25 In the same way, was not Rahab the harlot also justified by works when she received the messengers and sent them out by another way ? 26 For just as the body without the spirit is dead, so also faith without works is dead.
Next, here is the passage that would refute the works-basis for justification. This one comes from the letter of Paul to the Ephesians:
8 For by grace you have been saved through faith ; and that not of yourselves, it is the gift of God ; 9 not as a result of works, so that no one may boast.
This much shorter passage seems to contradict with the one from James. Does the Bible contradict? It sure seems so according to this, doesn't it? Perhaps there is a way to resolve this apparent conflict.
In order to do that, it is important to take a close look at some of the language of the passage. When we look at James 2:21, we see that what James is talking about is the concept of being "justified." The word being used here is dikaioo. One of the meanings of dikaioo is to show or exhibit or to be considered, to declare or to pronounce.
On the other hand, Paul refers to being "saved." The word used here is sozo which is to save, rescue, preserve from destruction. You can probably already see a significant difference between these two words. It is the difference between showing oneself righteous versus being rescued from harm.
The way this all breaks down is actually pretty simple. James was warning people that if you claim to be a follower of Christ but your life isn't changed, then you do not have a saving faith. Perhaps your faith is merely intellectual assent. But it is not a life-changing trust in Christ.
Paul, on the other hand, was referring to the idea that we do not earn our salvation. Our salvation is a free gift of God's grace. James was not saying that Abraham earned his salvation. He showed that he trusted God when he went to sacrifice his son, Isaac. It was an act of faith (e.g. trust). It did not earn Abraham salvation, it merely indicated salvation.
As it turns out, the passages are not contradictory because in order to contradict, you have to have two statements that mean mutually exclusive things. Or, to use the technical terminology:
A cannot be Non-A at the same time and in the same way.
It's that second part that where we find that this is not a contradiction. Because one refers to being rescued and the other refers to showing oneself justified by living a changed life. So, they do not say mutually exclusive things.
Now that we've gone through the biblical evidence, not to mention a very brief logic lesson, it seems that it is clear that we do not earn our salvation, but we should show that our lives are altered once we accept Christ as our Lord and Saviour.
For more resources: