Interestingly, the answer to this question is often presented as an absolute yes or an absolute no. If you answered with an absolute no then congratulations for being an antinomian (google it, somewhat to my own surprise I spelt this right first attempt), you're also wrong. And if you answered with an absolute yes then you're probably a Catholic or legalist and likewise wrong. The answer to the question is probably best summed up as a qualified yes (or even a qualified no but I think I prefer the emphasis on the doing of good). It requires a nuanced understanding of salvation and if you're wondering what on earth I'm going on about, please stay with me, at least until I've gone through the arguments.
Of course, one of the cornerstone principles of the Christian faith is salvation through faith alone. Happily, I'm not denying this. But salvation is much broader than we often conceive it to be. Let's spilt salvation into its parts then, sorry if you are put off with the '-ations' but it's good to learn the theological terms involved.
"For he [God] chose us in him before the creation of the world to be holy and blameless in his sight. In love he predestined us for adoption to sonship through Jesus Christ, in accordance with his pleasure and will— to the praise of his glorious grace, which he has freely given us in the One he loves." Ephesians 1 v 4 - 6
As the above verses says, before this world was created God predestined specific human beings to be his people, adopted into his family through Jesus Christ. The important point here is to notice the grounds of this predestining - the pleasure and will of God. Hence, it is not down to any works on our part. This is vital to grasp for a proper understanding of salvation. It begins with God's work of predestination, which is not based on any merit within us but rather his pleasure and will.
We're all on much more comfortable territory here. Justification describes the act of being justified before God, being made righteous. And the Bible confirms again and again that this is by faith alone. As Jesus says: "Very truly I tell you, whoever hears my word and believes him who sent me has eternal life and will not be judged but has crossed over from death to life." (John 5v24) The only requirement to be justified is belief, i.e. faith.
But if faith is required does not faith become a work? It would be a work, but this faith is not our own but rather a gift from God. As it is written: "For it is by grace you have been saved, through faith—and this is not from yourselves, it is the gift of God-- not by works, so that no one can boast. (Ephesians 2v8 - 9) On what grounds does God give this gift of faith? He gives it to all he has predestined. Our salvation from start to finish is a work of God.
Our righteous standing before God must rest securely on Jesus Christ and his righteousness. For in justification, Christ's righteous becomes ours and God's wrath against our sin is paid out on Christ. As Scripture says: "God made him who had no sin to be sin for us, so that in him we might become the righteousness of God." (2 Corinthians 5 v 21)
As you can see, we have dealt with two of the parts of salvation and not seen head nor tail of works. But while salvation is necessarily predestination and justification; it is not sufficiently these two things. There is also the next two parts: sanctification and glorification.
I quoted from Ephesians 2, a few paragraphs ago, in defence of justification by faith alone. But it's worth quoting the next verse: "For we are God’s handiwork, created in Christ Jesus to do good works, which God prepared in advance for us to do." (2v10) As is mentioned a lot in the Bible, we are not justified and left alone, we are not declared righteous and left to our own devices. Indeed, on of the signs of a false profession of faith is someone who does not do the good works God's law requires. For we are justified in order to do good works. As such good works become a necessary part of salvation.
As Jesus says: "If you love me, keep my commands." (John 14v15) The evidence of loving Jesus is obeying him. God is in the business of making all his people more holy, degree by degree. This isn't a linear process nor is it a process without much slipping back on our part; it's a messy, painful, failure strewn path. Take notice of the record of Abraham, Moses, David, Jonah, Peter, Paul (any of God's people); note their triumphs and note their gross sin. But the general trend of the Christian life is increasing holiness. As Paul writes: "I am sure of this, that he who began a good work in you will bring it to completion at the day of Jesus Christ." (Philippians 1v6).
Good works are a necessary consequence of our justification. They are also a necessary declaration of our justification. James writes: "faith without deeds is dead." and this is what he is speaking of. He cannot be contradicting Paul (in the bit from Ephesians) when he writes: "You see that a person is considered righteous by what they do and not by faith alone." (James 2v24) for Scripture cannot contradict Scripture for that would make God a liar.
Good works are, if you like, talking about different sides of the salvation coin. Paul is talking about the justification side and that faith alone is necessary. James is talking about a necessary consequence of our justification, which is the doing of good works, the sanctification side of the coin.
Have you ever wondered why Judgement Day is often described as a judgement of works? "And I saw the dead, great and small, standing before the throne, and books were opened. Another book was opened, which is the book of life. The dead were judged according to what they had done as recorded in the books." (Revelation 20v12)
Christians gain eternal life by the work of Christ, not by merit, but we will also be judged according to the resultant good deeds, for our good works declare our justification by faith. In Romans Paul marvelously declares that a justification apart from the law can be ours through faith in Christ. But he also writes: "God will repay each person according to what they have done. To those who by persistence in doing good seek glory, honour and immortality, he will give eternal life." (Romans 2v6-7)
He can write this and still be consistent because good works are a product, a necessary result, of our faith in Christ.
Hopefully, this leaves you wanting to do more good works. Do them, not because they justify you, but because they are a way of declaring the wonderful grace of God in saving you! Obedience is first and foremost an expression of love of Christ and it beholds us as Christians, indeed, it is necessary for us as Christians, to strive to live holy lives.
And as a final thought, I've got a quote from a Puritan for you to ponder on (you may wish to use a dictionary, I did!)
"They [good works] are related to justification not antecedently, efficiently or meritoriously, but consequently and declaratively. They are related to sanctification constitutively because they constitute and promote it. They are related to glorification antecedently and ordinatively because they are related to it as the means to the end." Francis Turretin