Let (M, I) be an almost complex 6-manifold. The obstruction to integrability of the almost complex structure (the so-called Nijenhuis tensor) N : Λ 0,1 (M ) −→ Λ 2,0 (M ) maps a 3-dimensional bundle to a 3-dimensional one. We say that Nijenhuis tensor is non-degenerate if it is an isomorphism. An almost complex manifold (M, I) is called nearly Kähler if it admits a Hermitian form ω such that ∇(ω) is totally antisymmetric, ∇ being the Levi-Civita connection. We show that a nearly Kähler metric on a given almost complex 6-manifold with non-degenerate Nijenhuis tensor is unique (up to a constant). We interpret the nearly Kähler property in terms of G 2 -geometry and in terms of connections with totally antisymmetric torsion, obtaining a number of equivalent definitions.We construct a natural diffeomorphism-invariant functional I −→ M Vol I on the space of almost complex structures on M , similar to the Hitchin functional, and compute its extrema in the following important case. Consider an almost complex structure I with non-degenerate Nijenhuis tensor, admitting a Hermitian connection with totally antisymmetric torsion. We show that the Hitchin-like functional I −→ M Vol I has an extremum in I if and only if (M, I) is nearly Kähler.