Living organisms must acquire new biological functions to adapt to changing and hostile environments. Deepwater rice has evolved and adapted to flooding by acquiring the ability to significantly elongate its internodes, which have hollow structures and function as snorkels to allow gas exchange with the atmosphere, and thus prevent drowning. Many physiological studies have shown that the phytohormones ethylene, gibberellin and abscisic acid are involved in this response, but the gene(s) responsible for this trait has not been identified. Here we show the molecular mechanism of deepwater response through the identification of the genes SNORKEL1 and SNORKEL2, which trigger deepwater response by encoding ethylene response factors involved in ethylene signalling. Under deepwater conditions, ethylene accumulates in the plant and induces expression of these two genes. The products of SNORKEL1 and SNORKEL2 then trigger remarkable internode elongation via gibberellin. We also demonstrate that the introduction of three quantitative trait loci from deepwater rice into non-deepwater rice enabled the latter to become deepwater rice. This discovery will contribute to rice breeding in lowland areas that are frequently flooded during the rainy season.