In timing-based neural codes, neurons have to emit action potentials at precise moments in time. We use a supervised learning paradigm to derive a synaptic update rule that optimizes via gradient ascent the likelihood of postsynaptic firing at one or several desired firing times. We find that the optimal strategy of upand downregulating synaptic efficacies depends on the relative timing between presynaptic spike arrival and desired postsynaptic firing. If the presynaptic spike arrives before the desired postsynaptic spike timing, our optimal learning rule predicts that the synapse should become potentiated. The dependence of the potentiation on Current address: Department of Complexity Science and Engineering, Graduate School of Frontier Sciences, The University of Tokyo. Current address: IDIAP, Rue du Simplon 4, Case Postale 592, CH-1920 Martigny. 1