“God who lifts me up from the gates of death.” There is no escape from death except by being raised from the dead by God, and because of that, death is compared to a prison that has “gates” and from which no one can escape without God’s help. These “gates” are referred to as the “gates of Sheol” (Job 17:16; Isa. 38:10) and “the gates of death” (Job 38:17; Ps. 9:13; 107:18). Jesus Christ referred to the gates in Matthew 16:18 where in many versions they are translated as “the gates of Hell.”
Here the psalmist is using “gates of death” to refer to being close to death. When the psalmist thinks it might be the end for him, God rescues him from death.
[For more on the gates of death, see commentary on Matt. 16:18. For more on Sheol, see commentary on Rev. 20:13. For more on dead people being dead, lifeless in every way, see Appendix 4, “The Dead are Dead.”]