According to The Mahabharata, Ashwatthaman means "the horse-voiced". It is so called because when he was born he cried like a horse.
Ashwatthama was the son of Dronacharya and Kripi. Drona did many years of severe penance to please Lord Shiva in order to obtain a son who possesses the same valiance as Lord Shiva. Born a Chiranjivi, Ashwatthama was born with a gem in his forehead which gives him power over all living beings lower than humans; it protected him from hunger, thirst, and fatigue.
Once, when Ashwatthama was a child, he desired to drink milk, like he had seen friends drink. Not even owning a cow, Ashwatthama painted his lips with a mixture of wheat flour with water, making it seem as if he had drank milk. This scene saddened Dronacharya. He remembered his childhood friend Drupada, who in a spurt of youthful exuberance, had promised to give Drona half of whatever he had. Dronacharya went to the court of Drupada to make good on that promise, but instead, was rebuked and humiliated by Drupada.
After this incident and seeing the plight of Dronacharya, Kripacharya, invited Drona to Hastinapur. There, he came upon the attention of his co-disciple Bhishma. Thus, Dronacharya became the guru of the Pandavas and of the Kauravas in Hastinapur. Ashwatthama was trained in the art of warfare along with them.
Bhishma himself declared that it will be virtually impossible for anyone to kill or defeat Ashwatthama in war as he is the part incarnate of Lord Shiva and he because was born to become a Chiranjivi. Bhishma said when Ashwatthama becomes angry then it will be impossible to fight him as he becomes a second Shiva. No one can handle his wrath and fury. Bhishma told Duryodhana
Lord Krishna and sage Vyasa also knew about this and they advised Arjuna to seek the blessing of Lord Shiva. Lord Shiva blessed victory to Arjuna but warned that it is impossible for anyone to kill Ashwatthama or agitate his anger.
Since Hastinapura, ruled by King Dhritarashtra, offered Dronacharya the privilege of teaching the Kuru princes, both Dronacharya and Ashwatthama were loyal to Hastinapur and fought for the Kauravas in the Kurukshetra war. Before Dronacharya's death, Ashwatthama visited his father, desiring a blessing of victory, but Dronacharya refused. He advised Ashwatthama to win the war using his own strength and not through a blessing from him.
Despite his friendship with the Pandavas, Ashwatthama had great familiarity with Duryodhana. He was attracted to Duryodhana's gregarious nature, and to Duryodhana's largesse bestowed upon him. Moreover, just as Duryodhana believed that the Pandavas were taking his birthright to the crown, Ashwatthama felt that Arjuna was usurping his place in Drona's heart.
Ashwatthama is a notable figure in the war and engages in many battles, though not scoring any significant kills until after his father's death.
On the 10th day of the war, Bhishma falls, and Drona is named the supreme commander of the armies. He promises Duryodhana that he will capture Yudhishthira, but then he repeatedly fails to do so. Duryodhana taunts and insults him, which greatly angers Ashwatthama, causing friction between Ashwatthama and Duryodhana. Lord Krishna knew that it was not possible to defeat an armed Drona. So, Krishna suggested to Yudhishthira and the other Pandavas, if Drona were convinced that his son was killed on the battlefield, then he'd disarm himself in grief.
Krishna hatched a plan for Bhima to kill an elephant by the name Ashwatthama while claiming to Drona it was Drona's son who was dead. Ultimately, the gambit works (though the details of it vary depending on the version of the Mahabharata), and Drona undergoes meditation to search for Ashwatthama's soul. Dhristadyumna beheads the unarmed, unaware sage.
Enraged, Ashwatthama unleashed Narayanastra, a weapon gifted to him by his father, on the Pandava army. Only Drona, Ashwatthama, and Lord Krishna possessed the knowledge of this weapon. Krishna tells the Pandavas and their warriors to drop their weapons and lie down on the ground, so that they all surrender completely to the power of this weapon. When targeted, Bhima refuses to surrender thinking that it as a cowardly act, and attacks the downpour of fiery arrows. The Narayana weapon, intensified by resistance, concentrates its shower on him, and he gets steadily exhausted and severely injured. However, he was not killed as Krishna and his brothers restrained him and forced him to surrender, thus saving their army.
According to the Chatahurdi compilation, the Narayana astra destroyed one Akshauhini of Pandava army completely. After the use of Narayana astra, terrible war between both armies took place. Ashwatthama defeated Dhrishtadyumna in direct combat, but failed to kill him as Satyaki and Bhima covered his retreat. Terrible war took place between the warriors of both sides as Ashwatthama forced both Satyaki and Bhima to withdraw. In his fury, Ashwatthama manages to kill King Nila of Mahismati.
Despite his animosity, after the death of Dushasana, Ashwatthama still suggested Duryodhana that he make peace with the Pandavas, keeping in mind the welfare of Hastinapur. Later, after Duryodhana is struck down by Bhima and facing death, the last three survivors from the Kaurava side, Ashwatthama, Kripa and Kritvarma rush to his side. There, they bemoan the cheap tactics the Pandavas have used, and bemoan the injustices done to them. Ashwatthama swears to bring Duryodhana revenge, and Duryodhana appoints him as the commander-in-chief.
On the night a very disturbed and restless Ashwatthama was sitting sleepless under a large tree planning about future actions to be taken. An owl ambushing a group of crows caught his attention. This gave him an idea of attacking the Pandava camp at night. The three surviving warriors proceeded to the Pandava camp. Kripa and Kritavarma guarded the exits while Ashwatthama proceeded into the camp.
At this point, there are different versions of the story. According to the analysis done by scholar Chatahurdi compilation, once arriving at the Pandava camp, they found a Bhairava blocking their entry. So Ashwatthama worshiped Lord Shiva for the fulfillment of his desires, offering himself as an oblation. This offering pleased Lord Shiva and Goddess Parvati; Shiva and Parvati in her most ferocious Kali form appeared before Ashwatthama with their gana's. Also, there appeared millions of Kali Sakthis, Kalika Nityas and Kalika Yoginis. They eagerly awaited for the impending massacre. In this version of the story, Shiva enters the body of Ashwatthama, granting him a polished sword. Kali and all of their ganas, Kalika Nityas, Sakthis, Yoginis, and other henchmen join in on the attack. It is Ashwatthama's possession by Shiva that explains his prowess.
Ashwatthama first kicked and woke up Dhrishtadyumna, the commander of the Pandava army and the killer of his father Drona. Ashwatthama strangled the half-awake Dhrishtadyumna to death as the Panchal prince begged to be allowed to die with a sword in his hand. Ashwatthama proceeds with slaughtering the remaining warriors, including Shikhandi, Yudhamanyu, Uttamaujas, and many other prominent warriors of the Pandava army. Those who tried to flee from Ashwatthama's wrath were hacked down by Kripacharya and Kritavarma at the camp's entrance.
At this point, there are numerous different versions of the story. In some, Ashwatthama mistakes the sleeping Upapandavas as the Pandavas and kills them. In others, he knows he is killing the Upapandavas and does so because he cannot find the Pandavas.
After the slaughter, the three warriors go to find Duryodhana. Again, the story has many versions at this point. In some, they find Duryodhana already dead, and mourning, they perform the cremation rights. In others, they find Duryodhana alive; Ashwatthama knows he hasn't killed the Pandavas but lies that he did in order to give his friend some happiness in death. Alternatively, Ashwatthama doesn't know he actually killed the Upapandavas and just reports what he thinks is the truth. In a final version, Ashwatthama tells Duryodhana that he killed the Pandava's children as the Pandavas were not there. There is more divergence; in some versions, this makes Duryodhana happy, as that means the Pandava lineage would die out. In others, this depresses him, as now the entire Kuru line will be defunct.
In all stories, after Duryodhana dies, the trio cremate his body.
The Pandavas and Krishna who were away during night, now returned to their camp the next day morning. Hearing the news of these events in the morning Yudhishthira fainted and the Pandavas become inconsolable. The Pandavas went searching for Ashwatthama to sage Vyasa's ashram. On seeing the approaching angered Pandavas, Ashwatthama as a last resort, devised a Brahmashirsha astra from a blade of grass and invoked it against the Pandavas and Krishna. Arjuna invokes the same astra, which he received by Drona itself, towards Ashwatthama.
On seeing the two powerful astra's heading for a head on cataclysmic (catastrophic) collision that would result in the total annihilation of the entire Earth, Vyasa stopped these divine weapons from colliding with each other by using his yogic power. He asked both these warriors to withdraw their respective weapons. Arjuna was able to withdraw his Brahmashirsha astra, while Ashwatthama could not do so as Drona did not teach his son how to withdraw it, thus limiting the power of Ashwatthama to use the astra for only one instance. Ashwatthama was given the option of deviating his weapon towards and uninhabited place, so that the astra could explode harmlessly. Out of rage, Ashwatthama instead directed the weapon towards the womb of the pregnant Uttara in an attempt to end the lineage of the Pandavas. The angered Pandavas wanted to kill Ashwatthama, but Sage Vyasa reminded them of the deceitful tactics they had used against the Kauravas.
As a punishment, Ashwatthama was asked to surrender the gem on his forehead. Disgusted, Krishna then cursed Ashwatthama that he will roam in the forests with blood and puss oozing out of his injuries and cry for death . Since he had no fear of death during war, death would not meet him. He will have neither any hospitality nor any accommodation; he will be in total isolation without any contact of physical communication from mankind and society. The wound caused by the removal of this gem on his forehead will not heal and his body will suffer from a host of incurable diseases forming sores and ulcers that would never heal .
In a Kannada version of Mahabaratha written by Kumara Vyasa, the author claimed that he wrote Mahabaratha by listening to Sage Ashwatthama. In order to escape from the curse, Ashwatthama approached his guru's guru Lord Parasurama, who was also an avatar of Lord Vishnu. Taking pity on him, Lord Parasurama agreed to help him. It was said that Ashwatthama was only an instrument in Lord Shiva's plan to exterminate all the evil people from earth. Hence, Ashwatthama was absolved of all sins. It was said that Pandavas met Ashwatthama once again 36 years later when they were travelling to seek pardon from Lord Shiva for their heinous crimes in war. The Pandavas found Ashwatthama happy in the company of Lord Parasurama and Sage Durvasa in an ashram on the banks of river Ganga. It was believed that Lord Parasurama and Maharishi Durvasa initiated Ashwatthama into Sakthi worship, which is considered to be the supreme of all modes of worship. By worshipping Adi ParaSakthi, Ashwatthama bypassed the curse of Lord Krishna.
It is said in ancient scriptures that "If God is angry at you, Guru can save you. But if Guru is angry at you, even God cannot save you". Alternate theories suggest that as per the words in scriptures Ashwatthama sought the help of his gurus and escaped the wrath of God, living along with his mother Kripi and his maternal uncle sage Kripa, both being great yogis somewhere in the Himalayas.
In one of the many side-stories of the Mahabharata, when Duryodhana was lying in the battle field, awaiting death, Krishna and he discuss the military mistakes he had made. One of these was not making Ashwatthama the commander-in-chief after the death of Dronacharya. If Duryodhana had made Ashwatthama as the commander of the army after the death of Drona, victory would have surely be his as Ashwatthama was the avatar of Lord Shiva. No one can handle a 'furious' Ashwatthama, the part incarnate of Lord Shiva. All Duryodhana needed to do to win the war was to make Ashwatthama furious. Just like Pandavas had Lord Krishna, the avatar of Lord Vishnu, Duryodhana had the avatar of Lord Shiva, but he never utilized Ashwatthama. The remorse about under utilizing Ashwatthama prompted Duryodhana to rethink and made Ashwatthama the commander of his army after the war, after his defeat.
According to the Chatahurdi compilation and analysis of the Mahabharatha, Ashwatthama is considered to be foremost among the rishis in Kaliyuga. Ashwatthama will become the next sage Vyasa, who in turn divide the Veda in 29th Mahayuga of 7th Manvantara. Ashwatthama will also become one of the Saptarishi in the 8th Manvantara along with sage Vyasa, sage Kripa and sage Parashurama. Ashwatthama studied Dhanurveda or martial arts and Brahmavidya or the science of the self or atma from Lord Parasurama, Maharishi Durvasa, Maharishi Ved Vyasa, Bhishma, Kripa and Drona. Ashwatthama is the master of all forms of knowledge and possesses complete mastery over 64 forms of arts or Kalas and 18 Vidyas or branches of knowledge.