I think there are four ways one can look at this.
Medical perspective
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).
Orthodox perspective
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. No one group can lay completely exclusive undisputed claim to the title "Orthodox", but that this was the historical view seems reasonably clear just from reading the Gospels. Modern groups that take the title Orthodox also tend to take this view: there are also demons now, even if they're more discreet than they used to be. Nonetheless, the demons still affect us and need to be battled, and they still possess people (and can be exorcised).
Unification perspective
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).
Diversification perspective
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. (This view blends into the Orthodox view, depending on whether any Biblical accounts of possession can be attributed to non-demonic mental illness instead. Many Orthodox churches recognize mental illness as a phenomenon. The Catholic Church in particular clearly recognizes mental illness as well as demonic possession, and I do not know whether doctrine indicates that some apparent cases of demonic possession should be understood as mental illness instead.)
Conclusion
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.