c. 1300, melancolie, malencolie, "mental disorder characterized by sullenness, gloom, irritability, and propensity to causeless and violent anger," from Old French melancolie "black bile; ill disposition, anger, annoyance" (13c.), from Late Latin melancholia, from Greek melankholia "sadness," literally (excess of) "black bile," from melas (genitive melanos) "black" (see melano-) + khole "bile" (see cholera).
Old medicine attributed mental depression to unnatural or excess "black bile," a secretion of the spleen and one of the body's four "humors," which help form and nourish the body unless altered or present in excessive amounts. The word also was used in Middle English for "sorrow, gloom" (brought on by love, disappointment, etc.), by mid-14c. As belief in the old physiology of humors faded out in the 18c. the word remained with a sense of "a gloomy state of mind," particularly when habitual or prolonged.
The Latin word also is the source of Spanish melancolia, Italian melancolia, German Melancholie, Danish melankoli, etc. Old French variant malencolie (also in Middle English) is by false association with mal "sickness."
When I go musing all alone,
Thinking of divers things fore-known,
When I build castles in the air,
Void of sorrow and void of fear,
Pleasing myself with phantasms sweet,
Methinks the time runs very fleet.
All my joys to this are folly,
Naught so sweet as melancholy.
When I lie waking all alone,
Recounting what I have ill done,
My thoughts on me then tyrannise,
Fear and sorrow me surprise,
Whether I tarry still or go,
Methinks the time moves very slow.
All my griefs to this are jolly,
Naught so sad as melancholy.
[Robert Burton, from "Anatomy of Melancholy," 17c.]