Melancholia (from Greek μελαγχολία melancholia "sadness", literally black bile), also lugubriousness, from the Latin lugere, to mourn; moroseness, from the Latin morosus, self-willed, fastidious habit; wistfulness, from old English wist: intent, or saturnine, was a concept in ancient and pre-modern medicine. Melancholy was one of the four temperaments matching the four humours. In the 19th century, "melancholia" could be physical as well as mental, and melancholic conditions were classified as such by their common cause rather than by their properties.
The name "melancholia" comes from the old medical belief of the four humors: disease or ailment being caused by an imbalance in one or other of the four basic bodily liquids, or humors. Personality types were similarly determined by the dominant humor in a particular person. According to Hippocrates and subsequent tradition, melancholia was caused by an excess of black bile, hence the name, which means 'black bile', from Ancient Greek μέλας (melas), "dark, black", and χολή (kholé), "bile"; a person whose constitution tended to have a preponderance of black bile had a melancholic disposition. In the complex elaboration of humorist theory, it was associated with the earth from the Four Elements, the season of autumn, the spleen as the originating organ and cold & dry as related qualities. In astrology it showed the influence of Saturn, hence the related adjective saturnine.
Melancholia was described as a distinct disease with particular mental and physical symptoms in the 5th and 4th centuries BC. Hippocrates, in his Aphorisms, characterized all "fears and despondencies, if they last a long time" as being symptomatic of melancholia. When a patient could not be cured of the disease it was thought that the melancholia was a result of demonic possession.  
In his study of French and Burgundian courtly culture, Johan Huizinga noted that "at the close of the Middle Ages, a sombre melancholy weighs on people's souls." In chronicles, poems, sermons, even in legal documents, an immense sadness, a note of despair and a fashionable sense of suffering and deliquescence at the approaching end of times, suffuses court poets and chroniclers alike: Huizinga quotes instances in the ballads of Eustache Deschamps, "monotonous and gloomy variations of the same dismal theme", and in Georges Chastellain's prologue to his Burgundian chronicle, and in the late fifteenth-century poetry of Jean Meschinot. Ideas of reflection and the workings of imagination are blended in the term merencolie, embodying for contemporaries "a tendency", observes Huizinga, "to identify all serious occupation of the mind with sadness".
Painters were considered by Vasari and other writers to be especially prone to melancholy by the nature of their work, sometimes with good effects for their art in increased sensitivity and use of fantasy. Among those of his contemporaries so characterised by Vasari were Pontormo and Parmigianino, but he does not use the term of Michelangelo, who used it, perhaps not very seriously, of himself. A famous allegorical engraving by Albrecht Dürer is entitled Melencolia I. This engraving has been interpreted as portraying melancholia as the state of waiting for inspiration to strike, and not necessarily as a depressive affliction. Amongst other allegorical symbols, the picture includes a magic square, and a truncated rhombohedron. The image in turn inspired a passage in The City of Dreadful Night by James Thomson (B.V.), and, a few years later, a sonnet by Edward Dowden.
The most extended treatment of melancholia comes from Robert Burton, whose The Anatomy of Melancholy (1621) treats the subject from both a literary and a medical perspective. Burton wrote in the 17th century that music and dance were critical in treating mental illness, especially melancholia.
But to leave all declamatory speeches in praise  of divine music, I will confine myself to my proper subject: besides that excellent power it hath to expel many other diseases, it is a sovereign remedy against  despair and melancholy, and will drive away the devil himself. Canus, a Rhodian fiddler, in  Philostratus, when Apollonius was inquisitive to know what he could do with his pipe, told him, "That he would make a melancholy man merry, and him that was merry much merrier than before, a lover more enamoured, a religious man more devout." Ismenias the Theban,  Chiron the centaur, is said to have cured this and many other diseases by music alone: as now they do those, saith  Bodine, that are troubled with St. Vitus's Bedlam dance.
During the later 16th and early 17th centuries, a curious cultural and literary cult of melancholia arose in England. In an influential 1964 essay in Apollo, art historian Roy Strong traced the origins of this fashionable melancholy to the thought of the popular Neoplatonist and humanist Marsilio Ficino (1433–1499), who replaced the medieval notion of melancholia with something new:
Ficino transformed what had hitherto been regarded as the most calamitous of all the humours into the mark of genius. Small wonder that eventually the attitudes of melancholy soon became an indispensable adjunct to all those with artistic or intellectual pretentions.
The Anatomy of Melancholy (The Anatomy of Melancholy, What it is: With all the Kinds, Causes, Symptomes, Prognostickes, and Several Cures of it... Philosophically, Medicinally, Historically, Opened and Cut Up) by Burton, was first published in 1621 and remains a defining literary monument to the fashion. Other major melancholic English authors whose works contain extensive meditations on death include Sir Thomas Browne, Hydriotaphia, Urn Burial (1658), and Jeremy Taylor with the conventionally religious Holy Living and Holy Dying (1650/51).
Night-Thoughts (The Complaint: or, Night-Thoughts on Life, Death, & Immortality), a long poem in blank verse by Edward Young was published in nine parts (or "nights") between 1742 and 1745, and hugely popular in several languages. It had a considerable influence on early Romantics in England, France and Germany. William Blake was commissioned to illustrate a later edition.
In the visual arts, this fashionable intellectual melancholy occurs frequently in portraiture of the era, with sitters posed in the form of "the lover, with his crossed arms and floppy hat over his eyes, and the scholar, sitting with his head resting on his hand"—descriptions drawn from the frontispiece to the 1638 edition of Burton's Anatomy, which shows just such by-then stock characters. These portraits were often set out of doors where Nature provides "the most suitable background for spiritual contemplation" or in a gloomy interior.
In music, the post-Elizabethan cult of melancholia is associated with John Dowland, whose motto was Semper Dowland, semper dolens. ("Always Dowland, always mourning.") The melancholy man, known to contemporaries as a "malcontent," is epitomized by Shakespeare's Prince Hamlet, the "Melancholy Dane."
A similar phenomenon, though not under the same name, occurred during the German Sturm und Drang movement, with such works as The Sorrows of Young Werther by Goethe or in Romanticism with works such as Ode on Melancholy by John Keats or in Symbolism with works such as Isle of the Dead by Arnold Böcklin. In the 20th century, much of the counterculture of modernism was fueled by comparable alienation and a sense of purposelessness called "anomie"; earlier artistic preoccupation with death has gone under the rubric of memento mori. The medieval condition of acedia (acedie in English) and the Romantic Weltschmerz were similar concepts, most likely to affect the intellectual.
The Arabic word found as ḥuzn and ḥazan in the Qur'an and hüzün in modern Turkish refers to the pain and sorrow over a loss, death of relatives in the case of the Qur'an. Two schools further interpreted this feeling. The first sees it as a sign that one is too attached to the material world, while Sufism took it to represent a feeling of personal insufficiency, that one was not getting close enough to God and did not or could not do enough for God in this world. The Turkish writer Orhan Pamuk, in the book Istanbul: Memories and the City, further elaborates on the added meaning hüzün has acquired in modern Turkish. It has come to denote a sense of failure in life, lack of initiative and tendency to retreat into oneself, symptoms quite similar to melancholia. According to Pamuk it was a defining character of cultural works from Istanbul after the fall of the Ottoman Empire. One may see similarities with how melancholic romantic paintings in the west sometimes used ruins from the age of the Roman Empire as a backdrop.
As a parallel with physicians of classical Greece, ancient Arabic physicians and psychologists also categorized ḥuzn as a disease. Al-Kindi (c. 801–873 CE) links it with disease-like mental states like anger, passion, hatred and depression, while the Persian physician Avicenna (980–1037 CE) diagnosed ḥuzn in a lovesick man if his pulse increased drastically when the name of the girl he loved was spoken. Avicenna suggests, in remarkable similarity with Robert Burton, many causes for melancholy, including the fear of death, intrigues surrounding one's life, and lost love. As remedies, he recommends treatments addressing both the medical and philosophical sources of the melancholy, including rational thought, morale, discipline, fasting and coming to terms with the catastrophe.
The various uses of ḥuzn and hüzün thus describe melancholy from a certain vantage point, show similarities with female hysteria in the case of Avicenna's patient and in a religious context it is not unlike sloth, which by Dante was defined as "failure to love God with all one's heart, all one's mind and all one's soul". Thomas Aquinas described sloth as "an oppressive sorrow, which, to wit, so weighs upon man's mind, that he wants to do nothing."
|Wikimedia Commons has media related to Melancholia.|