"Pray for me that I can take revenge on these infidels and pray for me that I will go to heaven," reads the note, left in the attacker's home.
The suspect, identified as a 17-year-old Afghan asylum-seeker, struck people with an axe onboard a train near the Germany city of Wuerzburg. Authorities say he shouted "Allahu akbar" throughout the rampage, an Arabic phrase meaning "God is great." He was shot dead by police.
Police found the suicide note in a notebook in the attacker's home, along with a Daesh flag.
German prosecutors claim that the attack may have been in response to learning of a friend's death in Afghanistan over the weekend.
Investigators are also investigating a video that appears to show the suspect brandishing a knife and vowing to use it to avenge those killed in Muslim countries. The authenticity of this video has not yet been verified, however.