1 Timothy 6
“But as for you, man of God, shun all this; pursue righteousness, godliness, faith, love, endurance, gentleness. Fight the good fight of the faith; take hold of the eternal life, to which you were called and for which you made the good confession in the presence of many witnesses. In the presence of God, who gives life to all things, and of Christ Jesus, who in his testimony before Pontius Pilate made the good confession, I charge you to keep the commandment without spot or blame until the manifestation of our Lord Jesus Christ, which he will bring about at the right time—he who is the blessed and only Sovereign, the King of kings and Lord of lords. It is he alone who has immortality and dwells in unapproachable light, whom no one has ever seen or can see; to him be honor and eternal dominion. Amen”
Jesus, being the Word made flesh, is God. He, as the Son of God, always possessed immortality, and then gained eternal life (by living in the flesh in obedience to the Spirit) on behalf of those who have faith in Him.