also brain-storm, by 1861 as a colloquial term for "fit of acute delirious mania; sudden dethronement of reason and will under stress of strong emotion, usually accompanied by manifestations of violence," from brain (n.) + figurative use of storm (n.).
The sense of "brilliant idea, mental excitement, fit of mental application," is by 1934 and seems to have evolved from the earlier sense:
Modern radio broadcasting is replete with examples of the resourcefulness, daring and hair-trigger thinking of the men who handle the big news breaks and special programs for the networks — the "brainstorm boys" the announcers and engineers call them. Eye-witness accounts of federal agents surrounding a gang lair, word pictures of dust storms, stratosphere flights, floods and fires — these are but a few of the programs brought to radio audiences by the brainstorm squad. [Popular Mechanics, July 1936]
The verbal meaning "make a concerted attack on a problem, involving spontaneous ideas," is by 1947. Related: Brainstormed; brainstorming.