In an affidavit released as the boy appeared in Clark County Juvenile Court, police said he claimed in the presence of school officials that a "voice in his head" was telling him to kill another 11-year-old student "for calling his friend ... 'gay.'"
Commissioner Dayann Liebman ordered a mental competency hearing. The boy remained in custody and his case will be reviewed Friday, The Columbian reported.
The boy was arrested Wednesday after police said he was found with a gun, knives and more than 400 rounds of ammunition at Frontier Middle School. No one was hurt, and the school was back to normal.
Police said the boy was arrested on suspicion of attempted murder, but court documents indicate the court found probable cause only for attempted assault, unlawful possession of a firearm and possession of a weapon at school. His name was not released.
The boy's mother called the school and said her son had taken some kitchen knives. The school resource officer took him to the principal's office where police said they found a .22-caliber handgun in his pants pocket and two loaded magazines in another pocket.
More ammunition and the knives were found in the backpack, police spokeswoman Kim Kapp said.
Police said in the affidavit the boy told authorities he planned to shoot the student he felt was bullying his friend "in the arm and then shoot himself in the head."
The school, which has 900 students, and nearby Pioneer Elementary School, which has about 600 students, were declared safe after a two-hour lockdown.
Parents were notified through social media and a letter sent home with students, said Evergreen Public Schools spokesman Kris Fay.
The boy has been expelled. He did not have a reputation as a troublemaker, Fay said.
"This kid has not been on the radar for this," he said.
The school will review the incident, but Fay said it appears all the protocols were followed.
"From the safety standpoint, everything went well yesterday," he said.