As per Shiva Purana, once Lord Brahma (the Hindu God of creation) and Lord Vishnu (the Hindu God of sustenance) had an argument in terms of supremacy of creation.To test them, Shiva pierced the three worlds as a huge endless pillar of light, the jyotirlinga. Lord Vishnu and Lord Brahma split their ways to downwards and upwards respectively to find the end of the light in either directions. Brahma lied that he found out the end, while Vishnu conceded his defeat. Shiva appeared as a second pillar of light and cursed Brahma that he would have no place in ceremonies while Vishnu would be worshipped till the end of eternity. The jyotirlinga is the supreme partless reality, out of which Shiva partly appears. The jyotirlinga shrines, thus are places where Shiva appeared as a fiery column of light.
The idol of Mahakaleshwar is known to be dakshinamurti, which means that it is facing the south. This is a unique feature, upheld by the tantric shivnetra tradition to be found only in Mahakaleshwar among the 12 Jyotirlingas. The idol of Omkareshwar Mahadev is consecrated in the sanctum above the Mahakal shrine. The images of Ganesh, Parvati and Karttikeya are installed in the west, north and east of the sanctum sanctorum. To the south is the image of Nandi, the vehicle of Lord Shiva. The idol of Nagchandreshwar on the third storey is open for darshan only on the day of Nag Panchami. The temple has five levels, one of which is underground. The temple itself is located in a spacious courtyard surrounded by massive walls near a lake. The shikhar or the spire is adorned with sculptural finery. Brass lamps light the way to the underground sanctum. It is believed that prasada (holy offering) offered here to the deity can be re-offered unlike all other shrines.
The presiding deity of time, Shiva, in all his splendor, reigns eternally in the city of Ujjain. The temple of Mahakaleshwar, its shikhar soaring into the sky, an imposing façade against the skyline, evokes primordial awe and reverence with its majesty. The Mahakal dominates the life of the city and its people, even in the midst of the busy routine of modern preoccupations, and provides an unbreakable link with ancient Hindu traditions. On the day of Maha Shivaratri, a huge fair is held near the temple, and worship goes on through the night.In the precincts of the Mahakaleshwar temple is Shri Swapaneshwar Mahadev temple, where devotees pray to Shiva as Mahakaal, to realize the most important dreams of their lives. Sadashiv Mahadev is so empathetic, benevolent and easy to please that devotees are sure to be granted the boons they wish for with a pure heart in this temple, it is believed. Here Mahadev is Swapaneshwar and Shakti is Swapaneshwari.The temple is open from 4 am to 11 pm.The temple is also glorified in 7th century.C.E , tamil tevaram hymns of tirugnanasambandar, sundarar, tirunavukkarasar and they refer to the same as tiru oonjai maakalam, oonjai being tamil name of word ujjain.
The Mahakaleshwar Temple as a Shakti Peeth
Shakti Peethas are shrines that are believed to have enshrined with the presence of Shakti due to the falling of body parts of the corpse of Sati Devi, when Lord Shiva carried it. Each of the 51 Shakti peethas have shrines for Shakti and Kalabhairava. The Upper Lip of Sati Devi is said to have fallen here and the Shakti is called as Mahakali.
References in Hindu scriptures
According to the Puranas, the city of Ujjain was called Avantika and was famous for its beauty and its status as a devotional epicenter. It was also one of the primary cities where students went to study holy scriptures. According to legend, there was a ruler of Ujjain called Chandrasena, who was a pious devotee of Lord Shiva and worshiped him all the time. One day, a farmer’s boy named Shrikhar was walking on the grounds of the palace and heard the King chant the Lord’s name and rushed to the temple to start praying with him. However, the guards removed him by force and sent him to the outskirts of the city near the river Kshipra. Rivals of Ujjain, primarily King Ripudamana and King Singhaditya of the neighboring kingdoms decided to attack the Kingdom and take over its treasures around this time. Hearing this, Shrikhar started to pray and the news spread to a priest named Vridhi. He was shocked to hear this and upon the urgent pleas of his sons, started to pray to Lord Shiva at the river Kshipra. The Kings chose to attack and were successful; with the help of the powerful demon Dushan, who was blessed by Lord Brahma to be invisible, they plundered the city and attacked all the devotees of Lord Shiva.
Upon hearing the pleas of His helpless devotees, Lord Shiva appeared in his Mahakala form and destroyed the enemies of King Chandrasena. Upon the request of his devotees Shrikhar and Vridhi, Lord Shiva agreed to reside in the city and become the chief deity of the Kingdom and take care of it against its enemies and to protect all His devotees. From that day on, Lord Shiva resided in His light form as Mahakala in a Lingam that was formed on its own from the powers of the Lord and His consort, Parvati. The Lord also blessed his devotees and declared that people who worshipped Him in this form would be free from the fear of death and diseases. Also, they would be granted worldly treasures and be under the protection of the Lord himself.
The temple complex was destroyed by Sultan Shas-ud-din Iltutmish during his raid of Ujjain in 1234-5. The present structure was built by the General of Srimant Peshwa Baji Rao and Chhatrapati Shahu Maharaj of the Hindu Pad Padshahi—Srimant Raanojirao Shinde Maharaj (Scindia) in 1736 AD. Further developments and management was done by Shreenath Mahadji Shinde Maharaj (Mahadji The Great) also known as Madhavrao Shinde the First (1730–12 February 1794) and Srimant Maharani Bayzabai Raje Shinde (1827–1863).
In the regime of Maharaja Shrimant Jayaajirao Saheb Shinde Alijah Bahadur until 1886, major programs of the then Gwalior Riyasat used to be held at this mandir. After Independence the Dev Sthan Trust was replaced by the municipal corporation of Ujjain. Nowadays it is under the collectorate office of Ujjain districrt.