Mantra is a sound or sequence of sounds, repeated over and over, vocalized, whispered, or repeated inwardly, as a meditative device. It is an important ingredient in some religious/yogic systems, and is emphasized much more in some systems than in others.
In Hinduism, for example, mantra is very conspicuous; within the sphere of Hinduism there may be thousands of mantras that are recited, from single syllables like Om or Rām, to longer sequences like Om nama Shivaya, Shri Rām jai Rām jai jai Rām, or the famous Hare Krishna chant, to very long, elaborate incantations, some of which are passages of Hindu scripture, and with some requiring elaborate purifications and initiations before receiving them, and which are given to a disciple for recitation under conditions of strict secrecy.
Even Christianity has some mantric traditions (and some people may be surprised to hear that Christianity has any yogic or meditative traditions), a few of the more well-known being repetition of the Lord's Prayer or "Hail Mary" by Roman Catholics manipulating rosaries, and the "Jesus Prayer" ("Lord Jesus Christ, Son of God, have mercy on me, a sinner"), which some Orthodox Christians learn to repeat throughout the day, every day, as a kind of constant "carrier wave." I imagine that, before long, people of such volition manage to keep the prayer going at night also, in their dreams.
In the realm of Buddhism, mantra is particularly favored in Mahayana. There was an early period in the composition of Mahayana texts wherein a mantra would be included at or near the end of a sutra, presumably as a way of epitomizing the message of the sutra vibrationally—with one of the most famous examples of this being the gate, gate, paragate, parasaṁgate, bodhi, svāha ("gone, gone, gone to the other shore, completely gone to the other shore, enlightenment, well said") of the Heart Sutra. Possibly the most famous of all Mahayana mantras is Om mani padme hum (approximately, "Om is the jewel in the heart of the lotus"). I have read that there is a school of Tibetan Buddhism called Mantrayāna, or the Mantra Vehicle, which no doubt rivals Hinduism in its masterful formulation of complicated esoteric sequences of sounds, for the purpose of producing spiritual effects. And in some schools of Pure Land Buddhism, simply repeating the name of Amitabha Buddha or Namu myōhō renge kyō x number of times every day is all that is really necessary for a good Buddhist, with all other practices being, at best, just frosting on the cake.
There are some who claim that a mantra, or rather a true mantra, possesses metaphysical power in and of itself. A fairly clear example of this is found in the Hare Krishna sect of Hinduism, which insists that only the frequent repetition of the divine names of God has any real power to liberate anyone from Samsara. I once read a Hare Krishna text (given to me free of charge) warning Hare Krishnas that they should not even associate with common meditators (they/we were called something like "moksha-vādins") who heretically expound the possibility of liberation through meditative insight. Also, there are many Hindus, and many followers of other religions too, who believe their scriptures to be inherently divine; and thus the words of these scriptures are viewed as bound to have infinitely greater spiritual power than the words of mere mortals.
Approaching the opposite extreme, there are some, and I think J. Krishnamurti was one of them, who claim that the specific content of a mantra is irrelevant; it may as well be Hey diddle diddle or Coca-Cola as Om mani padme hum, since its function is simply to occupy one's attention and keep the mind temporarily out of trouble. It still may be beneficial, however, since keeping the mind out of trouble may be a good thing, and since it may serve as a kind of psychological callisthenic exercise which improves self-discipline, allowing for us to be more the masters of our mind than for the mind to be master of us.
There are some teachers of Hinduism who adopt a peculiar intermediate position: They assert that Sanskrit, of all languages, was specially designed by ancient sages in such a way that certain Sanskrit syllables or words are "seed mantras" which stimulate specific spiritual vibrations in those who recite them repeatedly. Thus the syllable Om, or Aum, through some metaphysical quality not understood by Western science, really does instill a kind of primordial, universal "vibe" in people who use it as a mantra. I don't consider this Special Design of Sanskrit theory to be totally impossible, and it is endorsed by some very wise people, yet I can't help but be a bit skeptical. For one thing, if Sanskrit was specially designed as a spiritual language, it probably would have taken the form of fine adjustments performed in the development of Classical Sanskrit, post-dating Vedic Sanskrit, the latter mentioned being the form in which the most sacred scriptures of orthodox Hinduism were composed. Judging from what I have read, it is my understanding that the early speakers of Vedic Sanskrit who composed the Rig Veda were tribes of Indo-European barbarians who were not so different from other Bronze Age Indo-European barbarians, such as the Persians and Greeks, with regard to their attitudes toward the world, including their attitudes toward religion. (Theirs was a world of warlike kings and an aristocratic, polytheistic priesthood flattering and bribing the gods to grant them wealth, sons, and victory over their enemies—with some occasional philosophical reflection thrown in.) But all of this is guessing.
But regardless of the notion that Sanskrit is a specially designed mantric language, it is nevertheless pretty obvious that different sounds, and consequently different mantras, may cause different effects on an individual human's system; and thus the repetition of Om mani padme hum and of Coca-Cola may really generate significantly different effects. Anyone familiar with music or poetry, or even rhetoric, knows that different sounds elicit different feelings. A smooth, flowing sound is more likely to be calming and tranquility-facilitating than a rapid-fire staccato. The sound of a wooden flute is more likely to be calming than the sound of a brass trumpet. And if the sounds being repeated are meaningful words in a language one understands, then obviously the meaning of the words is very likely to have an affect/effect upon the person repeating them as a mantra. A word that a person sincerely believes to be a holy name of God is hardly probable to bear the same affective tone as Coca-Cola or some meaningless nonsense syllable like Bleen. (Then again, the effect of Bleen could be greatly enhanced if, after a disciple's intensive purifications and initiations a revered Guru were to say, "O my child, I now confer upon you as your sacred mantra the cosmic syllable of Bleen….") There was a time when I seriously considered cultivating as a mantra some lines of Shakespeare:
Life's but a walking shadow, a poor player
That struts and frets his hour upon the stage
And then is heard no more: it is a tale
Told by an idiot, full of sound and fury,
There is some Dharma in that, although whether the vibrational tone of it is spiritually pure or not, I can't say.
One peculiar example of words being formulated into a mantra is one that I read about many years ago: Some Tibetan lama (possibly of the Mantrayāna school) developed a mantra, the purpose of which was to help Tibetans to understand the Western mind. The mantra went something like, please please sorry thank you, please please sorry thank you… repeated over and over until the vibe or the feeling of it caused the meditator to feel more like a Westerner. Obviously, the purpose of all mantras is not necessarily Awakening.
Anyway, in the Pali Canon and the commentarial literature of Theravada Buddhism, mantra is not emphasized, and appears hardly to be mentioned at all. Of the forty standardized meditation techniques listed in texts like the Visuddhimagga, not one of them is specifically or necessarily a mantra technique. Some of them, over the course of time, have been converted into mantra techniques, however.
Probably the most well-known example, in Asia at least, of Theravadin mantra is the formulaic version of the meditations on the virtues of Buddha, Dhamma, and Sangha (which are three of the forty mentioned above). The formulas are extracted from the Suttas themselves, with the one on Buddha recited in Pali as follows:
itipi so bhagavā (And thus is that Blessed One,)
arahaṁ sammāsambuddho (the worthy one, the truly, fully enlightened one,)
vijjācaraṇa sampanno (attained to knowledge and conduct,)
sugato lokavidū (the fortunate one, knower of the world (or worlds),)
anuttaro purisadammasārathi (unsurpassed trainer of men to be tamed,)
satthā devamanussānaṁ (teacher of gods and human beings,)
buddho bhagavā (enlightened, the Blessed One.)
The formula for Dhamma begins svākkhāto bhagavatā dhammo ("Well expounded is the Way of the Blessed One…"), and the one for Sangha begins suppaṭipanno bhagavato sāvakasaṁgho ("Well-practiced is the Blessed One's congregation of disciples…"); if you're interested to learn them you can look them up for yourself. (Incidentally, according to the formulas the Buddha has nine qualities, Dhamma has six, and Sangha has nine, which is the source of 969, the trademark of the new militant Buddhist movement in Myanmar.) This meditation is commonly practiced with a rosary (seit badee in Burmese), with one complete recitation of the virtues of Buddha, Dhamma, and Sangha being counted by the thumbing of one bead.
One method which appears to be common in Thailand, but which I don't remember ever encountering in Burma, was explained to me once in a peculiar manner by an American man I know who had been briefly ordained as a monk in Thailand: He said that the object of meditation given to him was the repetition of "boot-toe." He evidently progressed with it at least to the level of upacāra-samādhi ("access concentration") without it occurring to anyone to explain to him that this is the Thai way of pronouncing buddho. I have read that buddho as a mantra is used in the Western Ajahn Chah tradition also.
An unusual form of Theravadin mantra found in my own ordination tradition, that is the Burmese Taungpulu forest tradition, is a variation of the reflection on the 32 parts of the body (another one of the forty standards). Instead of visualizing the shape, size, color, and location of each part, as the meditation is usually done, one simply repeats the names of the body parts as a mantra, following a very systematic method—the first five parts (head hair, body hair, nails, teeth, skin) for the first week, the same in reverse order the second week, the same forwards and backwards the third week, the second group of five for the fourth week, and so on. The idea, and I don't know where this idea came from, is that when sufficiently deep samādhi is attained with this mantra, insight into the true nature of the body parts will arise of itself, without the yogi bothering to think of the parts themselves. I've never practiced the meditation in this way myself, and I can't vouch for its effectiveness.
Mettā meditation also (another one of the forty) can be practiced as, or rather degenerate into, a kind of mantric formula, with little actual mettā going on. If one is trying to cultivate a loving heart one should be careful about this sort of thing.
In Burma, and very likely in Thailand too, on the outskirts of "genuine" Theravada, there is a kind of mantra in which astrologers, fortune tellers, wizards, or even labels on packages of incense, will offer a mantra in Pali, usually non-canonical and cooked up by some expert on such matters, for the purpose of inducing prosperity or otherwise granting wishes. This kind of mantra also is usually done with the aid of a rosary. This reminds me that some alchemists in Burma (called weiza or, if particularly adept, zawji) use mantras rather than metal-based compounds or runic diagrams called inn, to accomplish their occult feats. But this is moving out of the realm of Dhamma and into the realm of abracadabra—using the power of special words, or the belief in the power of special words, to manipulate mundane reality. I imagine that abracadabra mantras are even more common on the outskirts of Hinduism. Maybe even not so far from the middle.
I have learned from my own experience, practically accidentally, that mantra meditation has obvious benefits, especially at the mundane level. I discovered it "accidentally" because, around twelve years ago, I began noticing that I was spontaneously auming—that is, repeating the syllable "aum" under my breath with every exhalation—usually when I was walking, especially when walking to the village in the morning for alms. I still aum spontaneously, never deliberately deciding to do it, on average maybe two hours per day, especially when my eyes are open and I'm walking, riding in a car, waiting in line for something, or just sitting in a non-meditative context with nothing in particular to say. On the day of writing this, for example, I spent about an hour in an art gallery, auming almost continuously. I was there mainly to contemplate an elaborate, mind-blowing, beautiful surrealist work with a title like "Penetrating to the Spiritual"; I stared at it for maybe half an hour, pondering it, trying to understand it, while enthusiastically auming at it the whole time. It felt like it deserved to be aumed at, almost like it was calling out for it.
I intuitively prefer aum with three distinct sounds to om with a hard ō, like in the Upanishad (I don't remember which one) that compares the three sounds of AUM, plus the silence which follows it, to the four levels of consciousness: dreamless sleep, dreaming, ordinary waking, and Enlightenment, not necessarily in that order. I'm not sure why I prefer aum to om—for that matter, I'm not sure why I started automatically auming in the first place. When I first starting experimenting with meditation as a teenager I tried om as a mantra, but didn't keep it up for very long and didn't get far with it at all. (Its primordial simplicity, plus the fact that whatever meaning it has is beyond the intellectual level, are two reasons why I like it, though.) Maybe it's a previous life thing. I dunno.
One fairly obvious benefit of mantra that I learned quickly is that, completely setting aside any supernatural powers or naturally inspired higher vibrations, it is easier to keep one's mind focused on a mantra than when practicing the more commonly Theravadin method of mindfulness of breathing. A person who is sound asleep, or even more unconscious, as in a coma, continues breathing automatically; whereas, as far as I know, nobody in a coma repeats mantras. Mantra requires some conscious effort, even if it arises spontaneously, to keep it going. Because of this, one's mind is less likely to drift away to other things when practicing mantra than when practicing anapana; and even if it does drift away, it cannot drift away totally without the mantra stopping.
Also, a simple mantra like aum or buddho may be considered as a variation on anapana. After all, it's essentially a modified outbreath through the mouth. And one may combine it with a more ordinary form of anapana by cultivating mindfulness of the inbreath, and of the stillness in between in and aum. Breath is essential to mantra, unless maybe one does it entirely mentally, and even then one can't hold one's breath for very long.
It is often forgotten that there are two ways of going about Dharma: One is the development of good habits and goodness, which is the path of serenity and heaven; and the other is the abandonment of all habits, the relinquishment of both goodness and badness, the transcendence of all identity, and simply Waking Up from the whole dualistic dream. And really, only that which leads to full enlightenment can rightfully be called "True Dharma." You may be overflowing with benevolence, and you may have a "vibe" as rarified and subtle as you please, but it's not the same as Enlightenment. It's still just Samsara. It may eventually make it easier for you to become enlightened, and then again it may not. Sainthood and Enlightenment may appear to overlap in the same person, but they are not the same. In fact it may be seen that they are incommensurable; they are at two different levels of "reality," and one does not translate into the other. Bearing this in mind, even if some syllable is a mystically tuned "seed mantra" that can turn your spirit to solid gold, it is still hardly likely to enlighten you. And words, mere words, imbued with Divinity and the metaphysical power to induce Enlightenment, regardless of whether Gotama Buddha himself spoke them in the Pali language, do not, as far as I can tell, exist—at least not in an orthodox Theravada Buddhist universe. (But those of us who are not orthodox may believe as we please, at least theoretically.)
So we are left with the idea that merely repeating a mantra is hardly any more likely to enlighten us than merely breathing. To give an obvious and extreme example, outwardly mouthing a sacred formula while inwardly figuring out what you want to have for lunch is clearly not going to do the trick. But even if one's attention is focused on the mantra with undeviating crystal clarity, if it is repeated mechanically, with the momentum of one's mind pushing the mantra along a groove, so to speak, it may result in some amazing trance states and internal light shows, but it very probably still won't get a meditator enlightened. To the extent that it is momentum working in a groove, to that extent it is karmic and merely samsaric, a function of the dream.
It seems to me—and one can't afford to make categorical assertions on such issues, because anything may be possible—that one's best bet with mantra, as well as with breathing, is to do it as mindfully, or rather as consciously, as possible. So, one is presently aware of the entire mantra, from start to finish, as well as the silences in between. One is aware of the movements of one's mouth, the vibration in the throat (and even a whispered outbreath with aum has a distinct vibration). The mantra serves as a convenient center; although, if one can manage it, one is also presently aware of the process of seeing, of hearing, of the movements of one's body, of wind moving across the skin, and of anything else that arises. Consciousness expands outwards until there is no longer a clear boundary between "self" and "other," and one may experience at least a glimpse of what it's like not to have a habitual identity, and of the knowledge that losing one's identity is nothing to be feared. (In order to Wake Up, one has to let go of "me," and even of "one.")
Anyway, mindfulness of mantra may be a convenient and useful gimmick for cultivating mindfulness, even non-dual, non-discriminating mindfulness; and anything that you do mindfully is true yoga.