I am thinking before Yahweh, before Brahma, before Zoroaster, before any of the recorded gods in history. We know that at one point homo sapiens looked at the Sun and made it a "god", but we don't know who did it first or when. In that sense, we don't know who was the first group of people who came up with the idea of an afterlife, or how it was concocted, given that a number of cultures that seemingly never had contact with each other came with similar concepts.
I get the idea of the afterlife being a "cosmopolitan" concept... seems a valid argument can be made that ruling classes came up with it, trying to rationalize some form of immortality for themselves, or after declaring themselves living gods.