This paper studies sufficient conditions to obtain efficient distributed algorithms coloring graphs optimally (i.e. with the minimum number of colors) in the LOCAL model of computation. Most of the work on distributed vertex coloring so far has focused on coloring graphs of maximum degree Delta with at most Delta + 1 colors (or Delta colors when some simple obstructions are forbidden). When Delta is sufficiently large and c >= Delta - k(Delta) + 1, for some integer k(Delta) approximate to root Delta - 2, we give a distributed algorithm that given a c-colorable graph G of maximum degree Delta, finds a c-coloring of G in min{O((log Delta)(13/12) log n), 2(O(log Delta + root log log n))} rounds, with high probability. The lower bound Delta - k(Delta) + 1 is best possible in the sense that for infinitely many values of Delta, we prove that when chi(G) <= Delta - k(Delta), finding an optimal coloring of G requires Omega(n) rounds. Our proof is a light adaptation of a remarkable result of Molloy and Reed, who proved that for Delta large enough, for any c >= Delta - k(Delta) deciding whether chi(G) <= c is in P, while Embden-Weinert et al. proved that for c <= Delta - k(Delta) - 1, the same problem is NP-complete. Note that the sequential and distributed thresholds differ by one. Our first result covers the case where the chromatic number of the graph ranges between Delta - root Delta and Delta + 1. Our second result covers a larger range, but gives a weaker bound on the number of colors: For any sufficiently large Delta, and Omega(log Delta) <= k <= Delta /100, we prove that every graph of maximum degree Delta and clique number at most Delta -k can be efficiently colored with at most Delta - epsilon k colors, for some absolute constant epsilon > 0, with a randomized algorithm running in O(log n/log log n) rounds with high probability.