Insects use hydrocarbons as cuticular waterproofing agents and as contact pheromones. Although their biosynthesis from fatty acyl precursors is well established, the last step of hydrocarbon biosynthesis from long-chain fatty aldehydes has remained mysterious. We show here that insects use a P450 enzyme of the CYP4G family to oxidatively produce hydrocarbons from aldehydes. Oenocyte-directed RNAi knock-down of Drosophila CYP4G1 or NADPH-cytochrome P450 reductase results in flies deficient in cuticular hydrocarbons, highly susceptible to desiccation, and with reduced viability upon adult emergence. The heterologously expressed enzyme converts C(18)-trideuterated octadecanal to C(17)-trideuterated heptadecane, showing that the insect enzyme is an oxidative decarbonylase that catalyzes the cleavage of long-chain aldehydes to hydrocarbons with the release of carbon dioxide. This process is unlike cyanobacteria that use a nonheme diiron decarbonylase to make alkanes from aldehydes with the release of formate. The unique and highly conserved insect CYP4G enzymes are a key evolutionary innovation that allowed their colonization of land.