The earliest references to the city, as Ujjaini, 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.