Gene duplication provides a major source of new genes for evolutionary novelty and ecological adaptation. However, the maintenance of duplicated genes and their relevance to adaptive evolution has long been debated. Insect trehalase (Treh) plays key roles in energy metabolism, growth, and stress recovery. Here, we show that the duplication of Treh in Lepidoptera (butterflies and moths) is linked with their adaptation to various environmental stresses. Generally, two Treh genes are present in insects: Treh1 and Treh2. We report three distinct forms of Treh in lepidopteran insects, where Treh1 was duplicated into two gene clusters (Treh1a and Treh1b). These gene clusters differ in gene expression patterns, enzymatic properties, and subcellular localizations, suggesting that the enzymes probably underwent sub- and/or neofunctionalization in the lepidopteran insects. Interestingly, selective pressure analysis provided significant evidence of positive selection on duplicate Treh1b gene in lepidopteran insect lineages. Most positively selected sites were located in the alpha-helical region, and several sites were close to the trehalose binding and catalytic sites. Subcellular adaptation of duplicate Treh1b driven by positive selection appears to have occurred as a result of selected changes in specific sequences, allowing for rapid reprogramming of duplicated Treh during evolution. Our results suggest that gene duplication of Treh and subsequent functional diversification could increase the survival rate of lepidopteran insects through various regulations of intracellular trehalose levels, facilitating their adaptation to diverse habitats. This study provides evidence regarding the mechanism by which gene family expansion can contribute to species adaptation through gene duplication and subsequent functional diversification.