Understanding the evolution of pathogen resistance genes (also known as NLRs) within a species requires a comprehensive examination of factors that affect gene loss and gain. We present a new reference genome of Solanum chilense, that leads to an increased number and more accurate annotation of NLRs. Next, using a target-capture approach, we quantify the presence-absence variation (PAV) of NLR loci across 20 populations from different habitats. We build a rigorous pipeline to validate the identification of PAV of NLRs, then show that PAV is larger within populations than between populations, suggesting that maintenance of NLR diversity is linked to population dynamics. Furthermore, the amount of PAV is not correlated with the NLR presence in gene clusters in the genome, but rather with the past demographic history of the species, with loss of NLRs in diverging populations at the distribution edges and smaller population sizes. Finally, using a redundancy analysis, we find limited evidence of PAV being linked to environmental gradients. Our results contradict the classic assumptions of the important selective role of PAV for NLRs, and suggest that NLRs PAV is driven by random processes (and weak selection) in an outcrossing plant with high nucleotide diversity.