Ashwatthama was observing on the last day of the war, how an owl was attacked by crows in the day and how the owls attacked back in the night. So he surmised that under the laws of nature, a person can fight when he is strong. He, Kritavarma and Kripacharya tried to attack the camp of Pandavas and they were stopped by a demon kept by Krishna. However, Krishna also took the precaution of taking the Pandavas along with Satyaki to the river side of the Ganges.
Ashwatthama worshipped Shiva and offered his body as offering to Shiva. Shiva gave him the boon that whoever faces him that night shall die. Ashwatthama attacked the Pandava camp in the middle of the night, but by error ended up murdering the five sons of the Pandavas by Draupadi.
The Pandavas, incensed by this act, chased him resulting in his fight with Arjuna. During the fight, Ashwatthama invoked the extremely powerful Brahmashira weapon--which incidentally he had once tried to exchange with Krishna's discus without success--against Arjuna. Arjuna in response invoked the same weapon. Fearing the destruction of the world, the sages advised both to take back their weapons. While Arjuna could do so, Ashwatthama (presumably having less skill) could not and was given the option of choosing any single target to destroy. Out of spite, Ashwatthama directed the weapon to the wombs of Pandava women. Among them was Uttara, Arjuna's daughter-in-law.
At this time, Uttara was carrying the unborn Parikshit, son of Abhimanyu, who upon birth would be the future heir to all the Pandava brothers. The Brahmastra weapon was successful in fatally burning the foetus, but Krishna revived the stillborn child and cursed Ashwatthama with leprosy and to roam the world for 6,000 years as an unloved castaway. In another version, it is believed that he is cursed to remain alive till the end of the Kali Yuga. It is believed that Ashwatthama migrated to the land currently known as the Arabian Peninsula. Another version goes to say that he is still on Earth in the form of cyclones and typhoons. An old fort near Burhanpur, India called Asirgarh has a Lord Shiva temple on top where it is believed that Ashwatthama offers a red rose everyday to Lord Shiva early in the morning. Another story says that Ashwatthama is still roaming in the forest of Gir, Junagadh in the Gujarat state of India.
Ashwatthama also had to surrender a valuable gem, Mani, set on his forehead, the wearer of which ceases to have any fear from weapons or disease or hunger, and ceases to have any fear of gods, Danavas and Nagas.
Ashwatthama was one of the three survivors of the Kaurava army, along with Kritavarma and Kripacharya.