Gene gain/loss in the context of gene family dynamics plays an important role in evolutionary processes as organisms, particularly invasive species, adapt to new environments or niches. One notable example of this is the duplication of digestive proteases in some parasitic insects and helminths to meet nutritional requirements during animal parasitism. However, whether gene family expansion participates in the adaptation of a plant parasite nematode to its host remains unknown. Here, we compared the newly sequenced genomes of the pinewood nematode, Bursaphelenchus xylophilus, with the genomes of free‐living, animal‐parasitic and plant‐parasitic nematodes. The results showed gene expansions occurring in 51 gene families in B. xylophilus, especially in xenobiotic detoxification pathways, including flavin monooxygenase (FMO), cytochrome P450 (CYP450), short chain dehydrogenase (SDR), alcohol dehydrogenase (ADH), aldehyde dehydrogenase (ALDH), UDP‐glucuronosyltransferase (UGT) and glutathione S‐transferase (GST). Although a majority of these expansions probably resulted from gene duplications, nine ADH genes were potentially acquired by horizontal gene transfer (HGT) from fungi. From the transcriptomes of B. xylophilus treated with pine saplings and terpenes, candidate xenobiotic detoxification genes were identified. We propose that host defence chemicals led to gene family expansions of xenobiotic detoxification pathways in B. xylophilus facilitating its survival in pine resin ducts. This study contributes to a better understanding of how a parasitic nematode adapts to its host.