Quantum mechanics of the gravitational field