This article describes a recent study with an explanation for near-death experiences (NDE's). It suggests that the experiences are tricks the mind plays on itself as a result of a large amount of carbon-dioxide being released into the bloodstream.
There is evidence that people, who have either inhaled excess carbon-dioxide or been at high altitudes, have experienced sensations similar to NDE's, giving more credibility to the study. Anything that damages the brain can account for this experience, including excess carbon-dioxide.
Articles found here and here give similar views of the study.

There does not appear to be enough evidence to support this extraordinary claim. A scientist, who disputed this claim said, "There is no coherent cerebral activity which could support consciousness, let alone an experience with the clarity of a NDE. I'm sure it would be very easy for the researchers in charge of this study to fall victim to the confirmation bias. Of the 52 patients who were admitted to one of three hospitals after having a heart attack, only 11 of them reported a near-death experience. It seems likely that the researchers are looking for a correlation that might not be there. Not only is there evidence, in their own study, that the correlation may not exist, but it is based on some immeasurable variables. Yes, they can measure the carbon-dioxide levels, but to pair high levels with NDE's, how can the researchers tell if a patient actually experienced a NDE except by asking them and hoping they'll answer honestly? There will be instances where patients will experience a NDE and not remember and times when they don't experience a NDE and report that they did. This study seems flawed because it is based on the patients memory, which may not be flawless all the time.