On this question, the answer becomes understandable after addressing the confusion that arises from what one understands about:1.What salvation is and from what?
2. What is the mechanism of salvation?
3. Are we saved already or is this still future?
In reconciling the following 2 verses, I will make comments after quoting them:
A. Ephesians 2:8-9
“For by grace you have been saved through faith. And this is not your own doing; it is the gift of God, not a result of works, so that no one may boast.”
COMMENT: Salvation is indeed by grace of the Father and a gift, not by our own works. Mankind has been alienated from Father God because of sin. Everyone’s sin reverted or defaulted to, by imputation, to Adam’s sin((Rom.5:12-21), so that death, as a consequence thereof, could be imputed to Jesus’ death. But, the proximate result of the death of Christ is to reconcile us to Father God, i.e., his death did not proximately or actually save us. As Rom 5:10 states, “For if while we were enemies we were reconciled to God (through the death) of His Son, much more, having (been reconciled), we shall be saved by His life”. Notice, mankind has been reconciled to God by Jesus’ death but still (shall) be saved by his “life”, i.e., we will (still) need to be saved (future) by “his life”. Meaning, Jesus has to be resurrected to “life” before we can be saved. But, why does Jesus need to be resurrected? Notice in John 16:7 “Nevertheless I tell you the truth; It is expedient for you that I go away: for if I go not away, the Comforter will not come unto you; but if I depart, I will send him unto you.”
And, after resurrection what would Jesus do: Luke 24:49 “And, behold, I send the promise of my Father upon you: but tarry ye in the city of Jerusalem, until ye be imbued with power from on high.”
The “faith (of) Jesus” was for the Father after his death and resurrection, to provide the Spirit to be “in us”, as promised. It was prophesied that from a “stony heart” figuratively “tables of stone” that we had before, the Spirit will get into us to reside in the “fleshly tables of our heart” (2Cor.3:3;Ex.31:18; Ezekiel.11:19, 36:26; JeJer 31:33 changed from “stony heart” to “fleshly tables” of our heart, now open for learning, guidance and “wisdom”. As Pharaoh was “hardened and blind” (Ex 9:12), so were we “deaf and blind” (Jn 12:40; Mk 4:12; Isa 6:10) until the Spirit was given to us, starting on Pentecost. The Spirit is sorely needed by us because “the flesh is weak” (Matt 26:40-43).
Indeed, not our “own works”, but the “works” of Jesus’ dying and the Spirit given to mold us “like clay being shaped” (Isa 64:8; Jer 18:1-23; 18:2-6; Rom 9:21) into the mindset of Christ, the Head of the “body of Christ”, the church.
B. James 2:17-18
“So also faith by itself, if it does not have works, is dead. But someone will say, “You have faith and I have works.” Show me your faith r apart from your works, and I will show you my faith by my works.”
COMMENT: The context was about “showing”, our faith. The Spirit in us, molding the “spirit of man” will have “fruits of the spirit”(Gal 5:22-23). Our faith will then show or manifest in “good works”. Without these fruits manifested, how then can one be sure about the presence of faith?
In summary, salvation is being saved from the “second death” (Rev 20:14), where there is no resurrection. It is indeed by grace, a gift to us by the Father. This came about, not by “our works or our faith”. Rather, by Jesus’ works and faith in the promise of the Father. Yes, faith and works (of) Jesus. Because of Jesus’ death, we are then reconciled to the Father. After resurrection to “life”, the Spirit was given and dwelt in us, as it did to man-Jesus in the river Jordan at baptism. Having been imbued with this Spirit, we will then manifest the “fruits of the Spirit”. Faith without works is not shown and therefore dead, i.e. without proof that it existed in us. The actual realization of our salvation is still future at “the twinkling of an eye”(I Cor 15:52-57), at the second coming of Christ. True faith in God has to have works, manifested as “the fruits of the Spirit.” From faith-to-faith (Rom..1:17), i.e., from faith (of) Jesus (in) the Father, to our faith (in) Christ that transcends to the Father.