A student accused of opening fire at a Colorado school reportedly told investigators that he targeted peers who made fun of him for his gender identity, court documents show.

Alec McKinney, 16, and Devon Erickson, 18, allegedly decided to carry out the shooting after exchanging messages on social media the day before the May 7 attack at STEM School Highlands Ranch near Denver, the documents show.

The shooting resulted in the death of 18-year-old Kendrick Ray Castillo; eight others were injured.

The police records, which were unsealed Thursday, show McKinney telling officers in an interview that he intended to “shoot and kill” kids who made fun of him, “hated him” and called him “disgusting” and other names for being transgender.

ADVERTISEMENT

McKinney, who was born female, said he identifies as male and was beginning to transition.

He wanted “the kids at the school to experience bad things” and “suffer from trauma like he had to in his life,” court documents show.

McKinney reportedly reached out to Erickson on Snapchat the night before the shooting about carrying out the plan, but McKinney told investigators that he’d been planning the shooting for weeks.

McKinney reportedly told Erickson that he was “super suicidal” and that he wanted to get revenge on “a lot of people,” adding that he was thinking about killing his mom and siblings, court documents show.

Erickson said McKinney threatened to kill him and other students if he told anyone about the plan.

Both teenagers reportedly told police that they broke into a gun safe at Erickson's home before walking to the school with a guitar case and backpack concealing the firearms, according to the affidavit. Erickson reportedly took the two handguns used in the shooting from his parents, a law enforcement source told CNN, adding that both guns were purchased legally.

Erickson told law enforcement officials that the two used cocaine in his basement before going back to school. According to the affidavit, they used the middle school entrance because, they said, they knew they would be able to get the guns into the school from there.

Both students face criminal charges, including first-degree murder. McKinney has been charged as an adult, according to The Denver Post.