Numerous factors shape the evolution of protein-coding genes, including shifts in the strength or type of selection following gene duplications or changes in the environment. Diatoms and other silicifying organisms use a family of silicon transporters (SITs) to import dissolved silicon from the environment. Freshwaters contain higher silicon levels than oceans, and marine diatoms have more efficient uptake kinetics and less silicon in their cell walls, making them better competitors for a scarce resource. We compiled SITs from 37 diatom genomes to characterize shifts in selection following gene duplications and marine-freshwater transitions. A deep gene duplication, which coincided with a whole-genome duplication, gave rise to two gene lineages. One of them (SIT1-2) is present in multiple copies in most species and is known to actively import silicon. These SITs have evolved under strong purifying selection that was relaxed in freshwater taxa. Episodic diversifying selection was detected but not associated with gene duplications or habitat shifts. In contrast, genes in the second SIT lineage (SIT3) were present in just half the species, the result of multiple losses. Despite conservation of SIT3 in some lineages for the past 90-100 million years, repeated losses, relaxed selection, and low expression highlighted the dispensability of SIT3, consistent with a model of deterioration and eventual loss due to relaxed selection on SIT3 expression. The extensive but relatively balanced history of duplications and losses, together with paralog-specific expression patterns, suggest diatoms continuously balance gene dosage and expression dynamics to optimize silicon transport across major environmental gradients.