General anesthesia (GA) is an unconscious state produced by anesthetic drugs, which act on neurons to cause overall suppression of neuronal activity in the brain. Recent studies have revealed that GA also substantially enhances the dynamics of microglia, the primary brain immune cells, with increased process motility and territory surveillance. However, whether microglia are actively involved in GA modulation remains unknown. Here, we report a previously unrecognized role for microglia engaging in multiple GA processes. We found that microglial ablation reduced the sensitivity of mice to anesthetics and substantially shortened duration of loss of righting reflex (LORR) or unconsciousness induced by multiple anesthetics, thereby promoting earlier emergence from GA. Microglial repopulation restored the regular anesthetic recovery, and chemogenetic activation of microglia prolonged the duration of LORR. In addition, anesthesia-accompanying analgesia and hypothermia were also attenuated after microglial depletion. Single-cell RNA sequencing analyses showed that anesthesia prominently affected the transcriptional levels of chemotaxis and migration-related genes in microglia. By pharmacologically targeting different microglial motility pathways, we found that blocking P2Y receptor (P2YR) reduced the duration of LORR of mice. Moreover, genetic ablation of P2YR in microglia also promoted quicker recovery in mice from anesthesia, verifying the importance of microglial P2YR in anesthetic regulation. Our work presents the first evidence that microglia actively participate in multiple processes of GA through P2YR-mediated signaling and expands the non-immune roles of microglia in the brain.