A quantum theory of lasing in random media is presented. The theory constitutes a generalization of the standard laser theory, accounting for lasing in resonators with spectrally overlapping modes due to large outcoupling losses, and incorporating in a natural fashion the statistical properties of chaotic modes when apply to lasers in random media or inside chaotic resonators. We study the photocount statistics of the radiation emitted from a chaotic laser resonator in the regime of single-mode lasing. The random spatial variations of the resonator eigenfunctions are incorporated in the theory, and showed to lead to strong mode-to-mode uctuations of the laser emission. The distribution of the mean photocount over an ensemble of modes changes qualitatively at the lasing transition, and displays up to three peaks above the lasing threshold. We then address the quantization of the electromagnetic field in weakly confining resonators using Feshbach's projection technique. We consider both inhomogeneous dielectric resonators with a scalar dielectric constant epsilon(r) and cavities defined by mirrors of arbitrary shape. The field is quantized in terms of a set of resonator and bath modes. We rigorously show that the field Hamiltonian reduces to the system-and-bath Hamiltonian of quantum optics. The field dynamics is investigated using the inputoutput theory of Gardiner and Collet. In the case of strong coupling to the external radiation field we find spectrally overlapping resonator modes. The mode dynamics is coupled due to the damping and noise in icted by the external radiation field. We derived Langevin equations and a master equation for the resonator modes. For linear optical systems, including gain/loss contributions, it is shown that the field dynamics is described by the system S matrix. For wave chaotic resonator the dynamics is determined by a non-Hermitian random matrix. After including an amplifying medium, we use the open-resonator dynamics to construct a quantum theory for lasing in random media. We investigate the emission spectrum of lasers in cavities with overlapping modes operating in the single-mode regime. The noise properties of such lasers are seen to differ from traditional lasers due to the presence of excess noise. Our theory not only accounts for the Petermann linewidth enhancement, but predicts deviations of the laser line from a Lorentzian shape. To conclude, the emission spectrum of random lasers is discussed.