One among the seven scared cities.
The history of Ujjain temples is too old. Ujjain is mentioned in various puran and upnishad by its ancient names like Avantika, Ujjayani or Kanishka.
The earliest references to the city, as Ujjayani, are from the time of the Buddha, when it was the capital of the Avanti Kingdom. Since the 4th century B.C. the city has marked the first meridian of longitude in Hindu geography. It is also reputed to have been the residence of Ashoka (who subsequently became the emperor), when he was the viceroy of the western provinces of the Mauryan empire.
In the Post-Mauryan period, the city was ruled by the Sungas and the Satavahanas consecutively. It was contested for a period between the Satavahanas and the Ror Sakas (devotees of Shakumbari), known as Western Satraps; however, following the end of the Satavahana dynasty, the city was retained by the Rors from the 2nd to the 4th century CE. Ujjain is mentioned as the city of Ozene in the Periplus of the Erythraean Sea, an antique Greek description of sea ports and trade centers in the western Indian Ocean. Following the enthroning of the Gupta dynasty, the city soon became an important seat in the annals of that empire. Ujjain is considered to be the traditional capital of King Chandragupta II, also known as Vikramaditya, the legendary emperor, ruled the city with his famous Navratnas (nine jewels) including Kalidasa, Shanku, Dhanvantari, Betalbhatta, Varruchi, Varahmihir, Kshapdak, Ghatkarpar and Amar Singh who epitomised different branches of knowledge.
In the 6th and 7th centuries, Ujjain was a major center of mathematical and astronomical research. The famous mathematicians who worked there included: Brahmagupta, whose book Brahmasphutasiddhanta was responsible for spreading the use of zero, negative numbers and the positional number system to Arabia and Cambodia; Varahamihira, who was the first to discover many trigonometric identities; and Bhaskaracharya, or Bhaskara II, whose book Lilavati broke new ground in many areas of mathematics.
Ujjain was invaded by the forces of the Delhi Sultanate led by Iltutmish in 1235, suffering widespread destruction and systematic desecration of temples. Under the Mughal emperor Akbar it became the capital of Malwa. During the last half of the 18th century Ujjain was the headquarters of the Maratha leader Scindia. The Scindias later established themselves at Gwalior, and Ujjain remained part of Gwalior state until Indian Independence in 1947. Gwalior state became a princely state of the British Raj after the Maratha defeat in the Third Anglo-Maratha War, and Gwalior, Ujjain, and the neighboring princely states were made a part of the Central India Agency. After Indian independence, the Scindia ruler of Gwalior acceded to the Indian Union, and Ujjain became part of the Madhya Bharat state. In 1956 Madhya Bharat was merged into the Madhya Pradesh state.