Or did they just pass these people off as 'insane' or 'village idiots'?
edit: I forgot to specify Europe, though if people have info on this from other parts in the world, I'd be interested in it too.
I've written about this topic not too long ago, so I'll repost my answer to a very similar question:
It obviously depends on the region, but in rural medieval Britain and Ireland and elsewhere in Europe, mental disability would have been attributed to the actions of malevolent fairies. In general, it was believed that a child with mental disability (or at least this is what modern folklorists and historians have interpreted it as) was a 'changeling'; the offspring of a fairy, elf or some other supernatural being that had been left in the place of the parents' healthy, human baby which was taken away by the fairy.
Belief in the mechanisms that provoked supernatural beings to change offspring with humans varied by region - in Ireland, the malevolent feelings of others towards newborns might provoke it and in England mere neglect of a newborn would lead to its replacement. According to Keith Thomas, belief in fairies and changelings served several social functions: in this context it forced new parents to keep constant vigil over their babies so that it wouldn't be taken by fairies and replaced by a changeling. As well, it allowed parents to explain their children's disabilities without invoking their personal failures or sins (by contrast, leprosy was often perceived as the result of the sexual impurity of a victim's parents).
Now, I can't speak for how the mentally disabled were treated in general, but suspected changelings (who most historians identify as individuals on the autistic spectrum) were not treated very well in medieval Europe, to the extent that they might be tortured or killed by their parents. In general, 'cures' for changelings involved the deliberate mistreatment of the individual in order to provoke the fairies or supernatural creatures to return the parent's child. In England, one supposed 'cure' involved binding the changeling to a chair and leaving them on a dung heap in the mid day's sun, while elsewhere it was believed that casting a changeling into a fire or lit oven would force it to fly off and return with the original child, while the Welsh believed that identified changelings might be bathed in poisonous foxglove. Interestingly, it was commonly believed that boiling eggshells could force a changeling to speak from Wales to Spain and Ireland.
There are references to "imbeciles" and "natural fools" and the like in medieval records, yes. As early as the 1160s, Pierre, abbot of Andernes was complaining about monasteries becoming a dumping ground for the mentally and physically disabled and drunkards of noble families (Traditio, 1947, "L'organisation scholaire au XIIe siecle", cited by Delehaye). It's often repeated that the mentally handicapped/disabled were employed as jesters, but Irina Metzler finds little evidence that this was so (A Social History of Disability in the Middle Ages, 2013). The mid-thirteenth century law book, De Legibus et Consuetudinibus Angliae, states that the mentally disabled could not be held liable for their actions and no contract entered into by a mentally disabled person would be held valid.
I have heard that there was facility for mental ill people in XIV century Cracow, Poland