James 2:24 reads "Ye see then how that by works a man is justified, and not by faith only."
This passage should make it clear to the honest Bible student that works do have a role in our salvation (Heb 5:9, Rev 22:14, II Cor 5:10, Acts 10:34-35, I Pet 1:22, I John 2:17, Rev 20:12, Matt 7:21, etc.).
Some don’t want to accept what God says on this topic, so they try to find ways to get around the plain meaning of James 2:24. They say that James 2:24 is only talking about justification before men, and not salvation from sin. But the James 2 context rules out this meaning. This section begins in verse 14 with the question – can a man’s faith save him if he doesn’t have works? This is obviously talking about salvation from sin / eternal salvation as it refers to faith being a condition of that salvation. James then spends the rest of the chapter answering that question. He answers it "no" in verses 17, 20, 24, and 26. So verse 24 is an answer to the question, can faith without works save? And God’s answer is that works justify, not faith only.
Eph 2:8-9 and James 2:24 are not contradictory at all. Eph 2:8-9 is discussing the basis for our salvation (what earns it). That basis is the death/blood of Christ. James 2:24 is discussing whether or not receiving that salvation purchased by Christ is conditioned upon our works. It is. Believe what God said about it.