Microglia are the immune cells of the central nervous system that play important roles in brain pathologies. Microglia also help shape neuronal circuits during development, via phagocytosing weak synapses and regulating neurogenesis. Using in vivo multiphoton imaging of layer 2/3 pyramidal neurons in the developing somatosensory cortex, we demonstrate here that microglial contact with dendrites directly induces filopodia formation. This filopodia formation occurs only around postnatal day 8-10, a period of intense synaptogenesis and when microglia have an activated phenotype. Filopodia formation is preceded by contact-induced Ca(2+) transients and actin accumulation. Inhibition of microglia by genetic ablation decreases subsequent spine density, functional excitatory synapses and reduces the relative connectivity from layer 4 neurons. Our data provide the direct demonstration of microglial-induced spine formation and provide further insights into immune system regulation of neuronal circuit development, with potential implications for developmental disorders of immune and brain dysfunction.