Nonfunctional visual genes are usually associated with species that inhabit poor light environments (aquatic/subterranean/nocturnal), and these genes are believed to have lost function through relaxed selection acting on the visual system. Indeed, the visual system is so adaptive that the reconstruction of intact ancestral opsin genes has been used to reject nocturnality in ancestral primates. To test these assertions, we examined the functionality of the short and medium- to long-wavelength opsin genes in a group of mammals that are supremely adapted to a nocturnal niche: the bats. We sequenced the visual cone opsin genes in 33 species of bat with diverse sensory ecologies and reconstructed their evolutionary history spanning 65 million years. We found that, whereas the long-wave opsin gene was conserved in all species, the short-wave opsin gene has undergone dramatic divergence among lineages. The occurrence of gene defects in the short-wave opsin gene leading to loss of function was found to directly coincide with the origin of high-duty-cycle echolocation and changes in roosting ecology in some lineages. Our findings indicate that both opsin genes have been under purifying selection in the majority bats despite a long history of nocturnality. However, when spectacular losses do occur, these result from an evolutionary sensory modality tradeoff, most likely driven by subtle shifts in ecological specialization rather than a nocturnal lifestyle. Our results suggest that UV color vision plays a considerably more important role in nocturnal mammalian sensory ecology than previously appreciated and highlight the caveat of inferring light environments from visual opsins and vice versa.