  Let $(X,d,\mu)$ be a metric measure space. For $\emptyset\neq R\subseteq
(0,\infty)$ consider the Hardy-Littlewood maximal operator $$ M_R f(x)
\stackrel{\mathrm{def}}{=} \sup_{r \in R} \frac{1}{\mu(B(x,r))} \int_{B(x,r)}
|f| d\mu.$$ We show that if there is an $n>1$ such that one has the
"microdoubling condition" $ \mu(B(x,(1+\frac{1}{n})r))\lesssim \mu(B(x,r)) $
for all $x\in X$ and $r>0$, then the weak $(1,1)$ norm of $M_R$ has the
following localization property: $$ \|M_R\|_{L_1(X) \to L_{1,\infty}(X)}\asymp
\sup_{r>0} \|M_{R\cap [r,nr]}\|_{L_1(X) \to L_{1,\infty}(X)}. $$ An immediate
consequence is that if $(X,d,\mu)$ is Ahlfors-David $n$-regular then the weak
$(1,1)$ norm of $M_R$ is $\lesssim n\log n$, generalizing a result of Stein and
Str\"omberg. We show that this bound is sharp, by constructing a metric measure
space $(X,d,\mu)$ that is Ahlfors-David $n$-regular, for which the weak $(1,1)$
norm of $M_{(0,\infty)}$ is $\gtrsim n\log n$. The localization property of
$M_R$ is proved by assigning to each $f\in L_1(X)$ a distribution over {\em
random} martingales for which the associated (random) Doob maximal inequality
controls the weak $(1,1)$ inequality for $M_R$.
