1590s, originally Scottish, "a sullen look," probably from gloom (v.) "look sullen or displeased" (late 14c., gloumen), of unknown origin; perhaps from an unrecorded Old English verb or from a Scandinavian source (compare Norwegian dialectal glome "to stare somberly"), or from Middle Low German glum "turbid," Dutch gluren "to leer." Not considered to be related to Old English glom "twilight" (see gloaming).
Sense of "darkness, obscurity" is first recorded 1629 in Milton's poetry; that of "melancholy, dejection, cloudiness or cheerless heaviness of mind" is from 1744; but gloomy with a corresponding sense is attested from 1580s.