The genetic imprinting of individual loci or whole chromosomes, as in imprinted X-chromosome inactivation in mammals, is established and reset during gametogenesis; defects in this process in the parent can result in disease in the offspring. We describe a sperm-specific chromatin-based imprinting of the X chromosome in the nematode Caenorhabditis elegans that is restricted to histone H3 modifications. The epigenetic imprint is established during spermatogenesis and its stability in the offspring is affected by the presence of a pairing partner during meiosis in the parental germ line. We observed that DNA lacking a pairing partner during meiosis, the normal situation for the X chromosome in males, is targeted for methylation of histone H3 at Lys9 (H3-Lys9) and can be silenced. Targeting unpaired DNA for silencing during meiosis, a potential hallmark of genome defense, could therefore have a conserved role in imprinted X-chromosome inactivation and, ultimately, in sex chromosome evolution.