Demons According to the Rambam – Eruvin 18b
The Gemara here relates that during the 130 years between the murder of Kayin and the birth of Sheis, Adam gave birth to רוחין ושידין ולילין — spirits, demons and lilliths [another kind of demon]. Yet, as is well known, the Rambam's position is that there are no such things as demons. How does he deal with this Gemara?
In Moreh Nevuchim 1:7, Rambam deals with this very Gemara. He explains that the concept of Tzelem Elokim with which Man was created is his intellectual capacity — and, with it, the pursuit of perfection by way of that intellectual capacity. People who do not seek to develop their minds in quest of perfection lack Tzelem Elokim. Such people are animals in human form — indeed, they are worse, as they possess an intellect with which they can perpetrate evil. It was to such people, says the Rambam, that Adam gave birth until Sheis was born, who then continued the heritage of Tzelem Elokim from Adam.
Alternatively, R' Avraham the son of the Rambam writes in his Maamar al Derashos Chazal that stories which involve demons occurred in a kind of prophetic vision [albeit a vision that did not involve specific communication from Hashem], in a person's mind. Accordingly, it may be that this Gemara refers to Adam's mindset for those 130 years in which he felt rejected by Hashem — his mind was incapable of productive, spiritual thought, but was mired in negative and harmful visions.