We investigate the evolutionary dynamics of a finite population of sequences adapting to NK fitness landscapes. We find that, unlike in the case of an infinite population, the average fitness in a finite population is maximized at a small but finite, rather than vanishing, mutation rate. The highest local maxima in the landscape are visited for even larger mutation rates, close to a transition point at which the population delocalizes (i.e., leaves the fitness peak at which it was localized) and starts traversing the sequence space. If the mutation rate is increased even further, the population undergoes a second transition and loses all sensitivity to fitness peaks. This second transition corresponds to the standard error threshold transition first described by Eigen. We discuss the implications of our results for biological evolution and for evolutionary optimization techniques.