Polarity is an essential feature of many cell types, including neurons that receive information from local inputs within their dendrites and propagate nerve impulses to distant targets through a single axon. It is generally believed that intrinsic structural differences between axons and dendrites dictate the polarized localization of axonal and dendritic proteins. However, whether extracellular cues also instruct this process in vivo has not been explored. Here we show that the axon guidance cue UNC-6/netrin and its receptor UNC-5 act throughout development to exclude synaptic vesicle and active zone proteins from the dendrite of the Caenorhabditis elegans motor neuron DA9, which is proximal to a source of UNC-6/netrin. In unc-6/netrin and unc-5 loss-of-function mutants, presynaptic components mislocalize to the DA9 dendrite. In addition, ectopically expressed UNC-6/netrin, acting through UNC-5, is sufficient to exclude endogenous synapses from adjacent subcellular domains within the DA9 axon. Furthermore, this anti-synaptogenic activity is interchangeable with that of LIN-44/Wnt despite being transduced through different receptors, suggesting that extracellular cues such as netrin and Wnts not only guide axon navigation but also regulate the polarized accumulation of presynaptic components through local exclusion.