Spontaneous activity generated in the retina is necessary to establish a precise retinotopic map, but the underlying mechanisms are poorly understood. We demonstrate here that neural activity controls ephrin-A-mediated responses. In the mouse retinotectal system, we show that spontaneous activity of the retinal ganglion cells (RGCs) is needed, independently of synaptic transmission, for the ordering of the retinotopic map and the elimination of exuberant retinal axons. Activity blockade suppressed the repellent action of ephrin-A on RGC growth cones by cyclic AMP (cAMP)-dependent pathways. Unexpectedly, the ephrin-A5-induced retraction required cAMP oscillations rather than sustained increases in intracellular cAMP concentrations. Periodic photo-induced release of caged cAMP in growth cones rescued the response to ephrin-A5 when activity was blocked. These results provide a direct molecular link between spontaneous neural activity and axon guidance mechanisms during the refinement of neural maps.