Components of the KDM7 family of histone demethylases are implicated in neuronal development and one member, PHF8, is often found to be mutated in cases of X-linked mental retardation. However, how PHF8 regulates neurodevelopmental processes and contributes to the disease is still largely unknown. Here, we show that the catalytic activity of a PHF8 homolog in Caenorhabditis elegans, JMJD-1.2, is required non-cell-autonomously for proper axon guidance. Loss of JMJD-1.2 dysregulates transcription of the Hedgehog-related genes wrt-8 and grl-16, the overexpression of which is sufficient to induce the axonal defects. Deficiency of either wrt-8 or grl-16, or reduced expression of homologs of genes promoting Hedgehog signaling, restores correct axon guidance in jmjd-1.2 mutants. Genetic and overexpression data indicate that Hedgehog-related genes act on axon guidance through actin remodelers. Thus, our study highlights a novel function of jmjd-1.2 in axon guidance that might be relevant for the onset of X-linked mental retardation and provides compelling evidence of a conserved function of the Hedgehog pathway in C. elegans axon migration.