A nonperturbative approach to quantum theory in curved spacetime and to quantum gravity, based on a generalization of the Wigner equation, is proposed. Our definition for a Wigner equation differs somewhat from what has otherwise been proposed---it being an extension of methods from Yang-Mills theory in flat spacetimes. It is an exact equation, equivalent to the Heisenberg equations of motion. The approach makes different approximation schemes possible; e.g., it is in principle possible to perform a systematic calculation of the quantum effects order by order. The method is illustrated with some simple examples and applications. A calculation of the trace of the renormalized energy-momentum tensor is done, and the conformal anomaly is thereby related to nonconservation of a current in $d=2$ dimensions and a relationship between a vector and an axial-vector current in $d=4$ dimensions. The corresponding ``hydrodynamic equations'' governing the evolution of macroscopic quantities are derived by taking appropriate moments. The emphasis is put on the spin-$\frac{1}{2}$ case, but it is shown how to extend to arbitrary spins. Gravity is treated first in the Palatini formalism, which is not very tractable, and then more successfully in the Ashtekar formalism, where the constraints lead to infinite order differential equations for the Wigner functions.