Central nervous system (CNS) infection by Mycobacterium tuberculosis is one of the most devastating complications of tuberculosis, in particular in early childhood. In order to induce CNS infection, M. tuberculosis needs to cross specialised barriers protecting the brain. How M. tuberculosis crosses the blood–brain barrier (BBB) and enters the CNS is not well understood. Here, we use transparent zebrafish larvae and the closely related pathogen Mycobacterium marinum to answer this question. We show that in the early stages of development, mycobacteria rapidly infect brain tissue, either as free mycobacteria or within circulating macrophages. After the formation of a functionally intact BBB, the infiltration of brain tissue by infected macrophages is delayed, but not blocked, suggesting that crossing the BBB via phagocytic cells is one of the mechanisms used by mycobacteria to invade the CNS. Interestingly, depletion of phagocytic cells did not prevent M. marinum from infecting the brain tissue, indicating that free mycobacteria can independently cause brain infection. Detailed analysis showed that mycobacteria are able to cause vasculitis by extracellular outgrowth in the smaller blood vessels and by infecting endothelial cells. Importantly, we could show that this second mechanism is an active process that depends on an intact ESX‐1 secretion system, which extends the role of ESX‐1 secretion beyond the macrophage infection cycle.