Dendrites distinguish between sister branches and those of other cells. Self-recognition can often lead to repulsion, a process termed "self-avoidance." Here we demonstrate that dendrite self-avoidance in Drosophila da sensory neurons requires cell-recognition molecules encoded by the Dscam locus. By alternative splicing, Dscam encodes a vast number of cell-surface proteins of the immunoglobulin superfamily. We demonstrate that interactions between identical Dscam isoforms on the cell surface underlie self-recognition, while the cytoplasmic tail converts this recognition to dendrite repulsion. Sister dendrites expressing the same isoforms engage in homophilic repulsion. By contrast, Dscam diversity ensures that inappropriate repulsive interactions between dendrites sharing the same receptive field do not occur. The selectivity of Dscam-mediated cell interactions is likely to be widely important in the developing fly nervous system, where processes of cells must distinguish between self and nonself during the construction of neural circuits.