We present a model unifying general relativity and quantum mechanics. The model is based on the (noncommutative) algebra \mbox{\cal A} on the groupoid \Gamma = E \times G where E is the total space of the frame bundle over spacetime, and G the Lorentz group. The differential geometry, based on derivations of \mbox{\cal A}, is constructed. The eigenvalue equation for the Einstein operator plays the role of the generalized Einstein's equation. The algebra \mbox{\cal A}, when suitably represented in a bundle of Hilbert spaces, is a von Neumann algebra \mathcal{M} of random operators representing the quantum sector of the model. The Tomita-Takesaki theorem allows us to define the dynamics of random operators which depends on the state \phi . The same state defines the noncommutative probability measure (in the sense of Voiculescu's free probability theory). Moreover, the state \phi satisfies the Kubo-Martin-Schwinger (KMS) condition, and can be interpreted as describing a generalized equilibrium state. By suitably averaging elements of the algebra \mbox{\cal A}, one recovers the standard geometry of spacetime. We show that any act of measurement, performed at a given spacetime point, makes the model to collapse to the standard quantum mechanics (on the group G). As an example we compute the noncommutative version of the closed Friedman world model. Generalized eigenvalues of the Einstein operator produce the correct components of the energy-momentum tensor. Dynamics of random operators does not ``feel'' singularities.