Learning of new skills may occur through Hebbian associative changes in the synaptic strength of cortical connections [spike-timing-dependent plasticity (STDP)], but how the precise temporal relationship of the presynaptic and postsynaptic inputs determines the STDP effects in humans is poorly understood. We used a novel paired associative stimulation protocol to repeatedly activate the short-latency connection between the posterior parietal cortex and the primary motor cortex (M1) of the left-dominant hemisphere. In different experiments, we systematically varied the temporal relationships between the stimuli and the preferential activation of different M1 neuronal populations by applying transcranial magnetic stimulation over M1 with different coil orientations and in different states of cortical excitability (rest vs muscular contraction). We found evidence for the existence of both Hebbian and anti-Hebbian STDP in human long-range connections. The induction of bidirectional long-term potentiation or depression in M1 depended not only on the relative timing between the stimuli but, crucially, on the stimulation of specific neuronal populations and the activity state of the cortex. Our findings demonstrate that these mechanisms are not fixed but susceptible to rapid adaptations. This sudden transition from anti-Hebbian to Hebbian plasticity likely involves local dynamics of interaction with different populations of postsynaptic neurons.