Females of most animal species are usually inseminated by more than one male, which allows sperm from different males to compete for fertilization. To prevent invasion of sperm from other males, Drosophila males elicit a rejection behavior in their mates after copulation. Using paired mutant males that, for the lack of accessory glands, are sterile, we show that this rejection behavior is induced exclusively by the secreted accessory gland products transferred to the female during copulation. Moreover, the activities of sperm and accessory gland products are complementary and interdependent: both sperm fertility and rejection behavior depend on accessory gland products whose prolonged activities, in turn, require the presence of sperm. Fertility of sperm from paired males can be restored by accessory gland products of spermless males in "copulation complementation" experiments. Our observations may have important implications for the role of sexual behavior in evolution and for the treatment of male sexual dysfunction in humans.