Let G be a permutation group acting on a set Ω. A subset of Ω is a base for G if its pointwise stabilizer in G is trivial. We write b(G) for the minimal size of a base for G. We determine the precise value of b(G) for every primitive almost simple sporadic group G, with the exception of two cases involving the Baby Monster group. As a corollary, we deduce that b(G) is at most 7, with equality if and only if G is the Mathieu group M_24 in its natural action on 24 points. This settles a conjecture of Cameron.