A juvenile accused of opening fire at a Colorado school last month that left one student dead and eight others wounded sought revenge on classmates who bullied him because he’s transgender, court documents released on Thursday revealed.

Alec McKinney, 16, told police he enlisted a second student, Devon Erickson, 18, to help him carry out the shooting at the Science, Technology, Engineering and Math (STEM) School in Highlands Ranch, Colorado.

Both teens are charged with first-degree murder and attempted murder in the May 7 rampage. Prosecutors have charged McKinney as an adult, but his lawyers are seeking to have his case moved to juvenile court.

Douglas County District Judge Theresa Slade had ordered the entire case file sealed until Thursday when she ruled that certain documents could be released.

In the file, McKinney – who's in the ‘pre-op stage of transitioning’ - is documented telling investigators he targeted one student who ‘called him names and said he was disgusting for trying to be a guy,’ the affidavit said.

Alec McKinney, 16, told police he targeted one student in the shooting because he ‘called him names and said he was disgusting for trying to be a guy,’ the affidavit said

Accomplice Devon Erickson, 18, told investigators McKinney masterminded the sickening scheme and threatened to kill him if he refused to help him carry it out

McKinney told police that he had planned the shooting for weeks and that he wanted other students to ‘experience bad things [and] to suffer from trauma like he has had to in his life and to realize that the world is a bad place’.

McKinney admitted that he fired two handguns into a classroom until both firearms were empty, police said.

Erickson told police under questioning that two students rushed him when he appeared in the doorway of a classroom and that when one of the students hit him, the ‘abrupt impact’ caused the handgun he was wielding to discharge.

‘Devon described being in shock and stated that he didn't want anyone to get shot,’ according to the affidavit.

Kendrick Castillo, 18, was shot dead and witnesses told police that he was among those who charged the gunman, but it is unclear who fired the fatal shot.

McKinney told investigators he planned to conclude his heinous scheme by committing suicide, but he didn’t know how to release the safety mechanism on the gun he’d fled from the classroom with.

McKinney told police that he had planned the shooting for weeks and that he wanted other students to ‘experience bad things [and] to suffer from trauma like he has had to in his life and to realize that the world is a bad place’

‘Devon repeatedly claimed he was going to stop [McKinney] but couldn’t articulate how or why he never told an adult [about the plan],’ a probable cause statement says

Erickson, however, insists he wasn’t a willing party in carrying out the shooting. Instead, the 18-year-old told police McKinney had threatened to kill him if he didn’t help him carry out his monstrous vision, adding that he considered reporting McKinney to authorities on several occasions.

‘Devon repeatedly claimed he was going to stop [McKinney] but couldn’t articulate how or why he never told an adult,’ a probable cause statement says.

According to the documents, the pair had only known each other for six months in the lead up to the shooting but how they met beyond being classmates wasn’t specified.

It’s alleged that the pair finally decided to action the plan during a chain of Snapchat messages on the evening of May 6 – just hours before the first shots rang out at STEM.

‘Devin told [McKinney] a few weeks prior that he parents owned guns and they were locked in a safe,’ investigators claim.

McKinney went on to tell investigators that he threatened Erickson with an ax inside the home, later motivating him to smash a lock on his parent’s safe with the tool.

Once inside, the pair armed themselves with three handguns, a 22-caliber rifle and several rounds of ammunition.

Kendrick Castillo, 18, was shot dead after witnesses told police that he was among those who charged the gunman, but it is unclear who fired the fatal shot

Nonchalantly walking through the front doors of STEM, the pair told cops they knew the weapons, which were concealed in a backpack and a guitar case, would go undetected

Both of the teens said they consumed cocaine, spray painted Erickson’s mom’s car and set it on fire in the garage, before heading off to school.

Nonchalantly walking through the front doors of STEM, the pair told cops they knew the weapons, which were concealed in a backpack and a guitar case, would go undetected.

So far, the documents have helped to provide the most detailed timeline of the events leading up to the attack so far, however, once inside the school, the two defendants’ views of the events differ slightly.

Erickson claims he saw McKinney reach for one of the guns and demand that everyone get down on the ground. Erickson then says two students rushed towards him, knocking him to the ground – prompting the ‘gun to go off’.

While on the floor, Erickson told cops he ‘heard more gunshots and yelling and screaming’.

He also ‘described being in shock and stated that he didn’t want anyone to get shot,’ according to the affidavit.

McKinney, however, says the pair entered the room simultaneously yelling, ‘nobody move’. He claimed he only starting shooting after Erickson fired the first shot.

McKinney then ‘shot the revolver until it was empty and then shot the Glock until it was empty,’ before a teacher and two students bundled him to the floor.

The documents say that at least 29 people were in the room when the two boys stormed through the classroom doors on the morning of May 7.

The documents also revealed that the school's private security guard, who has not been publicly named, fired twice at a responding officer from the Douglas County Sheriff's Office when he saw the muzzle of a gun appear around a corner.

The officer was not hit by the gunfire, but a bullet fired by the security guard struck and wounded a female student in an adjoining classroom.