We give a sharp spectral condition for the existence of odd cycles in a graph of given order. We also prove a related stability result.