Chemosynthetic symbioses between bacteria and invertebrates occur worldwide from coastal sediments to the deep sea. Most host groups are restricted to either shallow or deep waters. In contrast, Lucinidae, the most species-rich family of chemosymbiotic invertebrates, has both shallow- and deep-sea representatives. Multiple lucinid species have independently colonized the deep sea, which provides a unique framework for understanding the role microbial symbionts play in evolutionary transitions between shallow and deep waters. Lucinids acquire their symbionts from their surroundings during early development, which may allow them to flexibly acquire symbionts that are adapted to local environments. Via metagenomic analyses of museum and other samples collected over decades, we investigated the biodiversity and metabolic capabilities of the symbionts of 22 mostly deep-water lucinid species. We aimed to test the theory that the symbiont played a role in adaptation to life in deep-sea habitats. We identified 16 symbiont species, mostly within the previously described genus Ca. Thiodiazotropha. Most genomic functions were shared by both shallow-water and deep-sea Ca. Thiodiazotropha, though nitrogen fixation was exclusive to shallow-water species. We discovered multiple cases of symbiont switching near deep-sea hydrothermal vents and cold seeps, where distantly related hosts convergently acquired novel symbionts from a different bacterial order. Finally, analyses of selection revealed consistently stronger purifying selection on symbiont genomes in two extreme habitats - hydrothermal vents and an oxygen-minimum zone. Our findings reveal that shifts in symbiont metabolic capability and, in some cases, acquisition of a novel symbiont accompanied adaptation of lucinids to challenging deep-sea habitats.