The article is dedicated to the proof of the following cubical version of the
flat torus theorem. Let $G$ be a group acting on a CAT(0) cube complex $X$ and
$A \leq G$ a normal finitely generated abelian subgroup. Then there exists a
median subalgebra $Y \subset X$ which is $G$-invariant and which decomposes as
a product of median algebras $T \times F \times Q$ such that: (1) the action $G
\curvearrowright Y$ decomposes as a product of actions $G \curvearrowright
T,F,Q$; (2) $F$ is a flat; (3) $Q$ is a finite-dimensional cube; (4) $A$ acts
trivially on $T$. Some applications are included. For instance, a splitting
theorem is proved and we show that a polycyclic group acting properly on a
CAT(0) cube complex must be virtually abelian.