A decomposing body may not seem like an ideal meditation aid, but at some of Thailand’s tens of thousands of Buddhist temples, it is common to find monks reflecting while seated before a rotting corpse.

The practice of corpse meditation, largely limited to Thailand today, is an ancient concept in Buddhism, sanctioned by the Buddha himself. There are centuries-old murals and manuscripts depicting scenes of meditation next to different types of cadavers, some infested with worms, others cut in two or being picked at by crows.

The unpleasant sight and overpowering stench of flesh decaying in tropical heat can impart lessons about important Buddhist precepts, like nonattachment to one’s body and the impermanence of everything, said Justin McDaniel, a professor of religious studies at the University of Pennsylvania.

The ritual is viewed as a powerful way to learn selflessness, Professor McDaniel said, “and the more selfless you are, the closer you are to nirvana.”