Source: Mahabharata Tatparya Nirnaya Chapter 28
Duryodhana’s thighs were broken by Bhimasena. All the Pandavas left the warfield and Duryodhana was left alone. Dogs, foxes and Pisachas started to feast on Duryodhana’s body even as he was alive. Ashwathama, along with Kripa and Kritavarma, approaches Duryodhana and asks him what next can be done. Duryodhana asks him to ensure Pandavas are eliminated.
Duryodhana, in his mind, wants Ashwathama to kill the Pandavas, marry his wife and have children who can rule the Kingdom. Ashwathama understands this mindset of the evil Kaurava and mentally agrees to this proposal. Ashwathama and the other 2 enter a forest due to the fear of Pandavas and Lord Krishna. In the middle of the night, Ashwathama sees an owl killing lots of crows which were asleep. He wakes the other 2 and tells them God has shown him the way to eliminate Pandavas.
The three of them approach the camp of the Pandavas. There, there are stopped by a huge Bhuta, which is actually Shiva in his Ugra form. The Bhuta is seen surrounded by Lord Krishna in his numerous forms. Ashwathama gets scared but starts to fight the Bhuta. When he loses very badly, Ashwathama performs a manasa yagna. Lord Shiva then grants him many weapons and lets him enter the camp.
Ashwathama instructs Kripa and Kritavarma to stand guard at the gate and kill anyone who comes out alive. He then enters the tent of Drishtadyumna and kicks him on his chest. Dhrishtadyumna wakes up and tells Ashwathama to fight him like a Kshatriya and kill him, which Ashwathama rejects. Ashwathama reminds him of his Guru Droha. Since the death of Drona, Drishtadyumna used to see the dream of his death in this very manner. So he accepts his fate. Ashwathama strangulates him with the thread of his bow and kills him.
Ashwathama then kills Shikhandi, Yudhamanyu, Uttamoujas and Janamejaya (another son of Drupada) and proceeds towards the sons of Draupadi. The sons of Draupadi wake up and engage with him in battle but he kills all of them with his sword. Only Sharvatrata, son of Bhimasena born to the daughter of Kashi raja survives as he is in Kailasa due to a boon from Shiva. Ashwathama then kills Chekitana and the Kings of Chedi, Panchala, Karoosha and Kashi. In order to kill the women and children, he sets the entire camp on fire.
When people start running out of the camp due to the fire, Kripa and Kritavarma kill all of them. Only the charioteer of Dhrishtadyumna survives this massacre as he falls down amongst the dead and acts as if he too is dead. The charioteer rushes and meets Draupadi and narrates the entire episode. Draupadi informs Bhimasena about this who then proceeds on a chariot.
Ashwathama, meanwhile, takes the heads of the sons of Pandavas and happily approaches Duryodhana. Duryodhana dies seeing the heads. Fearing the Pandavas, Ashwathama, Kripa and Kritavarma all take different routes from the warfield. Bhimasena chases Ashwathama and defeats him in a fight. Ashwathama then invokes the Brahmashirostra and releases the same. Krishna and Arjuna also arrive there at that moment.
Krishna then tells Bhimasena and Arjuna about an earlier incident. When Krishna was once meditating on the sea shore, Ashwathama approaches him and asks him for his weapons. Ashwathama fails to even lift one weapon of Krishna. When asked, Ashwathama reveals that he wants the weapons to kill Krishna himself and make Duryodhana the ruler of the world. Krishna smiles and sends off Ashwathama.
Ashwathama prays before the release of the Astra that the entire Pandava clan should be destroyed by it. Arjuna, under the influence of Krishna, releases the very same astra after praying that all life forms, including Ashwathama, should be safe. The combination of the two astras is potent enough to destroy the Universe. Hence, Lord Veda Vyasa appears in the sky and stops the two astras midway. He chastises the two for invoking that weapon and orders them to take it back. Arjuna immediately obeys and does so. Ashwathama is unable to withdraw the weapon. Lord Krishna then reveals that Ashwathama had lost his Brahmacharya due to the tacit promise made to Duryodhana earlier about marrying his wife. Hence he is unable to withdraw the weapon.
Lord Veda Vyasa then orders Ashwathama to surrender the divine gem on his forehead. Ashwathama hands over the gem to Bhimasena. The gem grants miraculous powers and liberation from hunger, thirst and diseases. Ashwathama pays a heavy price. Krishna then asks him to divert the weapon so that at least one offspring of the Pandavas survives. Ashwathama accuses Krishna of trying to save his sister’s son becomes adamant that he will direct the weapon at Uttara’s uterus so that the unborn Parikshit is killed.
Lord Krishna then declares that no matter what Ashwathama does, he will save the offspring of the Pandavas and assures all that Pandava clan will rule the world for a 1000 years. He curses Ashwathama that he should roam around the earth in dirty robes, with a stinking odor and full of wounds on his body. Lord Veda Vyasa also curses Ashwathama in the same way.
Ashwathama prays to Lord Vyasa that he should be able to see him whenever he desires. Lord Vyasa grants him this boon.
In the next Dwapara Yuga, the same Ashwathama will take on the role of “Vyasa” and divide the Vedas.