melancholy (n.)
c.1300, "condition characterized by sullenness, gloom, irritability," 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 melanin) + khole "bile" (see Chloe). Medieval physiology attributed depression to excess of "black bile," a secretion of the spleen and one of the body's four "humors."

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."
melancholy (adj.)
late 14c., "with or caused by black bile; sullen, gloomy, sad," from melancholy (n.); sense of "deplorable" (of a fact or state of things) is from 1710.