Most bees are diurnal, with behaviour that is largely visually mediated, but several groups have made evolutionary shifts to nocturnality, despite having apposition compound eyes unsuited to vision in dim light. We compared the anatomy and optics of the apposition eyes and the ocelli of the nocturnal carpenter bee, Xylocopa tranquebarica, with two sympatric species, the strictly diurnal X. leucothorax and the occasionally crepuscular X. tenuiscapa. The ocelli of the nocturnal X. tranquebarica are unusually large (diameter ca. 1 mm) and poorly focussed. Moreover, their apposition eyes show specific visual adaptations for vision in dim light, including large size, large facets and very wide rhabdoms, which together make these eyes 9 times more sensitive than those of X. tenuiscapa and 27 times more sensitive than those of X. leucothorax. These differences in optical sensitivity are surprisingly small considering that X. tranquebarica can fly on moonless nights when background luminance is as low as 10(-5) cd m(-2), implying that this bee must employ additional visual strategies to forage and find its way back to the nest. These strategies may include photoreceptors with longer integration times and higher contrast gains as well as higher neural summation mechanisms for increasing visual reliability in dim light.