Based on recent insight into the thalamocortical system and its role in perception and conscious experience, a unified pathophysiological framework for hallucinations in neurological and psychiatric conditions is proposed, which integrates previously unrelated neurobiological and psychological findings. Gamma-frequency rhythms of discharge activity from thalamic and cortical neurons are facilitated by cholinergic arousal and resonate in networks of thalamocortical circuits, thereby transiently forming assemblies of coherent gamma oscillations under constraints of afferent sensory input and prefrontal attentional mechanisms. If perception is based on synchronisation of intrinsic gamma activity in the thalamocortical system, then sensory input to specific thalamic nuclei may merely play a constraining role. Hallucinations can be regarded as underconstrained perceptions that arise when the impact of sensory input on activation of thalamocortical circuits and synchronisation of thalamocortical gamma activity is reduced. In conditions that are accompanied by hallucinations, factors such as cortical hyperexcitability, cortical attentional mechanisms, hyperarousal, increased noise in specific thalamic nuclei, and random sensory input to specific thalamic nuclei may, to a varying degree, contribute to underconstrained activation of thalamocortical circuits. The reticular thalamic nucleus plays an important role in suppressing random activity of relay cells in specific thalamic nuclei, and its dysfunction may be implicated in the biological vulnerability to hallucinations in schizophrenia. Combined with general activation during cholinergic arousal, this leads to excessive disinhibition in specific thalamic nuclei, which may allow cortical attentional mechanisms to recruit thalamic relay cells into resonant assemblies of gamma oscillations, regardless of their actual sensory input, thereby producing an underconstrained perceptual experience.