Intracranial aneurysm (IA) is a life-threatening cerebrovascular condition, often fatal when complicated by subarachnoid hemorrhage. While Krüppel-like factor 6 (KLF6) has been implicated in cancer and cardiovascular pathologies, its role in IA remains largely unexplored. The present study aims to clarify KLF6’s involvement in IA and identify potential therapeutic agents, advancing understanding and management of this condition. Gene expression datasets GSE122897 and GSE15629 were retrieved from the GEO database for analysis. The study examined the impact of KLF6 on IA through immune cell profiling and hypoxia-related pathways. Weighted gene co-expression network analysis (WGCNA) was applied to identify KLF6-associated hub genes. Hypoxia-related genes were further characterized, and computational drug screening was performed to pinpoint potential therapeutics. Blood samples from IA patients and healthy controls were evaluated for endothelin-1 (ET-1), vascular hematoma factor (vWF), and KLF6 expression. An in vitro model of H₂O₂-induced injury in human brain vascular smooth muscle cells (HBVSMCs) was employed to assess the effects of KLF6 modulation and melatonin treatment. Patients with elevated KLF6 expression showed significant alterations in resting memory CD4⁺ T cells and monocyte populations. Gene set enrichment analyses revealed that four hypoxia-related pathways were strongly activated in the high KLF6 group. Six hub genes linked to hypoxia demonstrated robust correlations with KLF6 expression. Drug prediction analyses highlighted melatonin as a potential candidate for IA therapy. ET-1, vWF, and KLF6 levels were significantly increased in IA patients. In HBVSMCs, KLF6 intensified H₂O₂-induced cellular injury, an effect counteracted by melatonin treatment. KLF6 may serve as a novel therapeutic target in IA, and melatonin’s modulation of KLF6-related pathways could offer protective effects against IA progression.