Microglia constantly survey the brain microenvironment and rapidly adopt different phenotypes in response to environmental stimuli. Such dynamic functions require a unique metabolism and bioenergetics. However, little is known about the basic metabolism of microglia and how metabolic changes regulate microglia function. Here, we uncover that microglia activation is accompanied by extensive transcriptional changes in glucose and lipid metabolism‐related genes. Using metabolic flux assays, we found that LPS, a prototype of the pathogen‐associated molecular patterns (PAMPs), significantly enhanced glycolysis but suppressed oxidative phosphorylation (OXPHOS) in primary cultured microglia. By contrast, ATP, a known damage‐associated molecular pattern (DAMPs) that triggers sterile activation of microglia, boosted both glycolysis and OXPHOS. Importantly, both LPS and ATP activated the mechanistic target of rapamycin (mTOR) pathway and enhanced the intracellular reactive oxygen species (ROS). Inhibition of mTOR activity suppressed glycolysis and ROS production in both conditions but exerted different effects on OXPHOS: it attenuated the ATP‐induced elevation of OXPHOS, yet had no impact on the LPS‐induced suppression of OXPHOS. Further, inhibition of mTOR or glycolysis decreased production of LPS‐induced proinflammatory cytokines and ATP‐induced tumor necrosis factor‐α (TNF‐α) and brain derived neurotrophic factor (BDNF) in microglia. Our study reveals a critical role for mTOR in the regulation of metabolic programming of microglia to shape their distinct functions under different states and shed light on the potential application of targeting metabolism to interfere with microglia‐mediated neuroinflammation in multiple disorders.