The legendary history of Mahakala was written by Khedrup Khyungpopa, founder of the Shangpa Kagyu tradition, in the eleventh century. He says that the reason for the special powers and effectiveness of Mahakala goes back to Avalokiteshvara's vow to remain in the mortal world and not reach Buddhahood until all sentient beings were enlightened. After helping hundreds of thousands of people for countless years to reach enlightenment, Avalokiteshvara saw no decrease in suffering, but rather an increase in defilements. He then became discouraged. As soon as he had that thought, his head immediately split into a thousand pieces. Amitabha, one of the five transcendent Buddhas, put the pieces back together and made eleven heads, telling Avalokiteshvara to make the same promise again but to keep it better. Accordingly out of Avalokiteshvara's eleven faces, ten are peaceful, but one is wrathful, representing Mahakala.
Avalokiteshvara, saddened, fell unconscious for seven days, after which he thought that the world's suffering souls needed results in a hurry without excessive effort. He then wished to turn himself into a wrathful deity in order to defeat more rapidly and effectively the obstacles to the happiness of others. With this thought the letter HUM in dark blue color came out of his heart. That Hum became Mahakala. It is not without significance that in the mantra ‘Om Mani Padme Hum', the syllable Hum invokes energetic powers.
The birth of Mahakala was followed by an earthquake and with one voice the Buddhas in the heaven declared that he would have the power to grant all wishes if the wishes were honest and good.
Mahakala was the personal tutelary deity for the Mongol ruler Kublai Khan. His terrifying imagery ultimately derives from the angry form of the Hindu god Shiva, known as Bhairava. In Tibetan iconography he typically has one head with three bulging eyes. His eyebrows are like small flames, and his beard is made of hook-like shapes. He can have two to six arms.
The essential nature of Mahakala in the Tibetan pantheon can be gauged from the fact that he is worshipped as the Protector of the tent. Because of the nomadic nature of the Tibetan people, much of their life is spent in arduous and hazardous travel, complicated by the generally hostile environment they live in. During their sojourns, they use the Tent as a temporary abode, making it a very important part of their lives. He is also unquestionably the most vital Dharampala, since every monastery, no matter what the order, has a shrine devoted to this deity.