Q:

Which is the oldest scriptural reference for Diwali?

The festival of Diwali is associated with many legends:

The first day of Dhan Trayodashi is the day when Goddess Lakshmi appeared from the Samudra Manthan.
Next comes Narak Chaturdashi is when Lord Krishna killed the demon Narkasur.
The next day of Amavasya celebrated as Deep-awali is when Lord Rama and Sita returned to Ayodhya after defeating Ravan. 
This is followed by Govardhan Puja or Annakut on the next day.
The final day of the festival is Bhai-duj which is also called Yamadvitiya since it is associated with Yama, the god of Death and his sister Yamuna the second day after new moon.

Chronologically, I guess the Samudra Manthan episode could have come first followed by the Yam-Yamuna episode; then the Ramayan episode and finally the two days related to Krishna. My question is, which is the oldest reference to each of these celebrations?

A:

The oldest spiritual reference of Diwali is Vamana avatar according to Dashavatar book(Ten Avatars of Lord Vishnu).
When king Bali had defeated by the Lord Vamana. Later lord Vamana sent the Bali to the Hartal folk(पाताल लोक). Then all people who were scared by Bali, They celebrated like the festival and lit the lots of lamps.  
Then new fresh reference is Lord Rama According to Dashavatar Book. We all know about the whole story of Ram and Ravana.
Ravana defeated by Lord Rama at Lanka during Ram's exile. After this war, Lord Rama back to his own kingdom Ayodhya. All the people of Ayodhya have been waiting for his beloved Rama since 14 years. So, they started a lit of lamps and a warm welcome to Lord Rama.

