Microglial abnormality and heterogeneity are observed in autism spectrum disorder (ASD) patients and animal models of ASD. Microglial depletion by colony stimulating factor 1-receptor (CSF1R) inhibition has been proved to improve autism-like behaviors in maternal immune activation mouse offspring. However, it is unclear whether CSF1R inhibition has extensive effectiveness and pharmacological heterogeneity in treating autism models caused by genetic and environmental risk factors. Here, we report pharmacological functions and cellular mechanisms of PLX5622, a small-molecule CSF1R inhibitor, in treating Cntnap2 knockout and valproic acid (VPA)-exposed autism model mice. For the Cntnap2 knockout mice, PLX5622 can improve their social ability and reciprocal social behavior, slow down their hyperactivity in open field and repetitive grooming behavior, and enhance their nesting ability. For the VPA model mice, PLX5622 can enhance their social ability and social novelty, and alleviate their anxiety behavior, repetitive and stereotyped autism-like behaviors such as grooming and marble burying. At the cellular level, PLX5622 restores the morphology and/or number of microglia in the somatosensory cortex, striatum, and hippocampal CA1 regions of the two models. Specially, PLX5622 corrects neurophysiological abnormalities in the striatum of the Cntnap2 knockout mice, and in the somatosensory cortex, striatum, and hippocampal CA1 regions of the VPA model mice. Incidentally, microglial dynamic changes in the VPA model mice are also reported. Our study demonstrates that microglial depletion and repopulation by transient CSF1R inhibition is effective, and however, has differential pharmacological functions and cellular mechanisms in rescuing behavioral deficits in the two autism models.