Diwali dates back to ancient times in India, as a festival after the summer harvest in the Hindu calendar month of Kartika. The festival is mentioned in Sanskrit texts such as the Padma Purana, the Skanda Purana both completed in second half of 1st millennium AD but believed to have been expanded from a core text from an earlier era. The diyas (lamps) are mentioned in Skanda Purana to symbolically represent parts of sun, the cosmic giver of light and energy to all life, who seasonally transitions in the Hindu calendar month of Kartik.

Hindus in some regions of India associate Diwali with the legend of Yama and Nachiketa on Kartika amavasya (Diwali night). The Nachiketa story about right versus wrong, true wealth versus transient wealth, knowledge versus ignorance is recorded in Katha Upanishad composed in 1st millennium BC.

King Harsha in the 7th century Sanskrit play Nagananda mentions Deepavali as Deepapratipadutsava (Deepa = light, pratipada = first day, utsava = festival), where lamps were lit and newly engaged brides and grooms were given gifts. Rajasekhara referred to Deepavali as Dipamalika in his 9th century Kavyamimamsa, where in he mentions the tradition of homes being whitewashed and oil lamps decorating homes, streets and markets in the night. The Persian traveller and historian Al Biruni, in his 11th century memoir on India, wrote Deepavali being celebrated by Hindus on New Moon day of the month of Kartika.