I think there are four ways one can look at this.
There are no well-documented cases of demon possession today among vast numbers of illnesses; various mental health problems have been tracked down often to a physical cause (even if we don't understand all the details of how the flaws work). (See Wikipedia articles on epilepsy, schizophrenia, and so on.)
Historical accounts of people acting weirdly are generally consistent with the illnesses diagnosed (and treated, to some extent) today. Since there is no evidence for demon possession, and a quite satisfactory alternative hypothesis (allowing for some exaggerations during telling), we should conclude that there never was any demon possession; that the Bible mentions possession is just a historical artifact of how mental illness symptoms were viewed at the time of the New Testament (note that the Old Testament is curiously free of cases of demonic possession).
The Bible says there were demons, for example in Matthew 8:28-29:
Jesus Heals Two Men with Demons
28And when he came to the other side, to the country of the Gadarenes, two demon-possessed men met him, coming out of the tombs, so fierce that no one could pass that way. 29And behold, they cried out, "What have you to do with us, O Son of God? Have you come here to torment us before the time?"
So there were certainly demons then. There are presumably also demons now, but they're much more discreet than they used to be; still, you can still find them if you look hard enough.
Demonic possession and mental illnesses are two different ways to look at the same thing. When we say someone is possessed by jealousy, we don't mean that there is an evil spirit called Jealousy that is taking control of our actions. Instead, we mean that they are in a particular mood, one which induces them to do things that they might sorely regret were they in a calmer state of mind.
In this view, "demonic possession" is a spiritual perspective on mental illness: mental illness is a flaw ultimately enabled by evil, and so without the perspective of modern medicine, it is entirely reasonable to call states of mental dysfunction "demonic possession" (in the possessed by jealousy sense).
There are some mental illnesses and some demon possessions, and if something was called a "demon possession" in the New Testament but sounds like a mental illness, it was probably a mental illness.
Given a perspective, one can answer whether some/all cases of demon possession were actually mental illness. In the first and third views, they all were; in the fourth, some were, but picking out which was which is hard to do reliably (would require scriptural support, of which there is none that I am aware). In the second, no, demon possession was really the problem, just like it says.