An 11-year-old Washington state boy accused of taking a gun, knives and 400 rounds of ammunition to school erupted with profanities in court. Kyle Iboshi of NBC station KGW of Portland, Ore., reports.

An 11-year-old Washington state boy accused of taking a gun, knives and 400 rounds of ammunition to school last week yelled obscenities and fought detention officers after a judge ordered him to remain in custody.

The Clark County prosecutors office said Tuesday that the boy, whom NBC News isn't identifying because he's a juvenile, would be charged with attempted murder, theft of a firearm and other weapons charges.

Prosecutors said he'd changed his story to admit planning to shoot multiple people last Wednesday at Frontier Middle School in Vancouver, Wash.

Clark County Juvenile Court Commissioner Jennifer Snider rejected the testimony of a court-appointed psychologist who said the boy presented a low risk of threat to the community and ordered him returned to police custody.

"I feel that at this point, he needs to be held to protect him from himself and also (to protect) the community," Snider said after prosecutors told her the boy had threatened suicide at least once before.

As he was being led out of court, the boy started crying and screaming: "Get off me! Get the (expletive) off!" — as well as other curses.

In a declaration of probable cause filed last week, police said the boy had "claimed in the presence of school officials that a 'voice in his head' was telling him to kill" another student after he had called the boy's friend "gay."

But prosecutors told Snider that the boy later gave them a different story: that he actually planned to wait until after school to shoot several people.

Prosecutors said the boy had managed to sneak the gun onto school grounds at least twice before this month and that on the day of his arrest, he told a school counselor: "I'm not going to (expletive) tell you anything. You don't know what I'm capable of."