Termites host diverse communities of gut microbes, including many bacterial lineages only found in this habitat. The bacteria endemic to termite guts are transmitted via two routes: a vertical route from parent colonies to daughter colonies and a horizontal route between colonies sometimes belonging to different termite species. The relative importance of both transmission routes in shaping the gut microbiota of termites remains unknown. Using bacterial marker genes derived from the gut metagenomes of 197 termites and oneCryptocercuscockroach, we show that bacteria endemic to termite guts are mostly transferred vertically. We identified 18 lineages of gut bacteria showing cophylogenetic patterns with termites over tens of millions of years. Horizontal transfer rates estimated for 16 bacterial lineages were within the range of those estimated for 15 mitochondrial genes, suggesting that horizontal transfers are uncommon and vertical transfers are the dominant transmission route in these lineages. Some of these associations probably date back more than 150 million years and are an order of magnitude older than the cophylogenetic patterns between mammalian hosts and their gut bacteria. Our results suggest that termites have cospeciated with their gut bacteria since first appearing in the geological record.