Let $\Omega \subset \mathbb{R}^d$ be a set with finite Lebesgue measure such that, for a fixed radius $r>0$, the Lebesgue measure of $\Omega \cap B_r (x)$ is equal to a positive constant when $x$ varies in the essential boundary of $\Omega$. We prove that $\Omega$ is a ball (or a finite union of equal balls) provided it satisfies a nondegeneracy condition, which holds in particular for any set of diameter larger than $r$ which is either open and connected, or of finite perimeter and indecomposable. The proof requires reinventing each step of the moving planes method by Alexandrov in the framework of measurable sets.