Microglia play essential roles in central nervous system (CNS) homeostasis and influence diverse aspects of neuronal function. However, the transcriptional mechanisms that specify human microglia phenotypes are largely unknown. We examined the transcriptomes and epigenetic landscapes of human microglia isolated from surgically resected brain tissue ex vivo and following transition to an in vitro environment. Transfer to a tissue culture environment results in rapid and extensive downregulation of microglia-specific genes that are induced in primitive mouse macrophages following migration into the fetal brain. Substantial subsets of these genes exhibit altered expression in neurodegenerative and behavioral diseases and are associated with non-coding risk variants. These findings reveal an environment-dependent transcriptional network specifying microglia-specific programs of gene expression and facilitate efforts to understand the roles of microglia in human disease.