Let (X, d, μ) be a metric measure space. For ∅ = R ⊆ (0, ∞) consider the Hardy-Littlewood maximal operatorWe show that if there is an n > 1 such that one has the "microdoubling condition" μ(B(x, (1 + 1 n )r)) μ(B(x, r)) for all x ∈ X and r > 0, then the weak (1, 1) norm of M R has the following localization property:An immediate consequence is that if (X, d, μ) is Ahlfors-David n-regular then the weak (1, 1) norm of M R is n log n, generalizing a result of Stein and Strömberg (1983) [47]. We show that this bound is sharp, by constructing a metric measure space (X, d, μ) that is Ahlfors-David n-regular, for which the weak (1, 1) norm of M (0,∞) is n log n. The localization property of M R is proved by assigning to each f ∈ L 1 (X) a distribution over random martingales for which the associated (random) Doob maximal inequality controls the weak (1, 1) inequality for M R .