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 after transition to an in vitro environment. Transfer to a tissue culture environment resulted in rapid and extensive down-regulation of microglia-specific genes that were induced in primitive mouse macrophages after migration into the fetal brain. Substantial subsets of these genes exhibited altered expression in neurodegenerative and behavioral diseases and were associated with noncoding 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 brain diseases.