Photoreceptors (R cells) in the Drosophila retina connect to targets in three distinct layers of the optic lobe of the brain: R1-R6 connect to the lamina, and R7 and R8 connect to distinct layers in the medulla. In each of these layers, R axon termini are arranged in evenly spaced topographic arrays. In a genetic screen for mutants with abnormal R cell connectivity, we recovered mutations in flamingo (fmi). fmi encodes a seven-transmembrane cadherin, previously shown to function in planar cell polarity and in dendritic patterning. Here, we show that fmi has two specific functions in R8 axon targeting: it facilitates competitive interactions between adjacent R8 axons to ensure their correct spacing, and it promotes the formation of stable connections between R8 axons and their target cells in the medulla. The former suggests a general role for Fmi in establishing nonoverlapping dendritic and axonal target fields. The latter, together with the finding that N-Cadherin has an analogous role in R7 axon-target interactions, points to a cadherin-based system for target layer specificity in the Drosophila visual system.