Viral infections are a major cause of human disease. Although most viruses replicate in peripheral tissues, some have developed unique strategies to move into the nervous system, where they establish acute or persistent infections. Viral infections in the central nervous system (CNS) can alter homeostasis, induce neurological dysfunction and result in serious, potentially life-threatening inflammatory diseases. This Review focuses on the strategies used by neurotropic viruses to cross the barrier systems of the CNS and on how the immune system detects and responds to viral infections in the CNS. A special emphasis is placed on immune surveillance of persistent and latent viral infections and on recent insights gained from imaging both protective and pathogenic antiviral immune responses.