Odor detection involves hundreds of olfactory receptors from diverse families, making modeling of hedonic valence of an odorant difficult, even in Drosophila melanogaster where most receptors have been deorphanised. We demonstrate that a broadly tuned heteromeric receptor that detects CO2 (Gr21a, Gr63a) and other odorants is a key determinant of valence along with a few members of the Odorant receptor family in a T-maze, but not in a trap assay. Gr21a and Gr63a have atypically high amino acid conservation in Dipteran insects, and they use both inhibition and activation to convey positive or negative valence for numerous odorants. Inhibitors elicit a robust Gr63a-dependent attraction, while activators, strong aversion. The attractiveness of inhibitory odorants increases with increasing background CO2 levels, providing a mechanism for behavior modulation in odor blends. In mosquitoes, valence is switched and activation of the orthologous receptor conveys attraction. Reverse chemical ecology enables the identification of inhibitory odorants to reduce attraction of mosquitoes to skin.