HIGHLANDS RANCH, Colo. -- When a gunman burst into his high school classroom, Kendrick Castillo did not hesitate.
The 18-year-old immediately charged, pinning the attacker to the wall before Castillo was fatally shot protecting classmates, witnesses said. As he charged, so did two other students. One of them, Brendan Bialy, wrestled the gun from the shooter's hand and the students subdued him.
A second shooter was captured by an armed security guard.
Authorities said these acts of bravery helped minimize the bloodshed from Tuesday's attack, which also wounded eight people.
"We're going to hear about very heroic things that have taken place at the school," Douglas County Sheriff Tony Spurlock said Wednesday.
The attackers were identified by law enforcement officials as 18-year-old Devon Erickson and a 16-year-old who prosecutors identified as Maya McKinney but whose attorney said uses male pronouns and the name Alec. The two allegedly walked into the STEM School Highlands Ranch through an entrance without metal detectors and opened fire in two classrooms.
Because the attack happened only miles from Columbine High School and just weeks after the shooting's 20th anniversary, questions quickly arose about whether it was inspired by the 1999 massacre. But investigators offered no immediate motive.
Castillo sprang into action against the shooter "and immediately was on top of him with complete disregard for his own safety," said Bialy, a close friend of Castillo's who has signed up to join the Marines.
A member of the school's robotics club and a relentless tinkerer, Castillo had an infectious smile and gentle sense of humor, according to friends. He worked part-time at a local manufacturing company that had offered him a job after an internship because he was such a standout employee.
"To find he went down as a hero, I'm not surprised. That's exactly who Kendrick was," said Rachel Short, president of the company, Baccara.
Cecilia Bedard, 19, had known Castillo since elementary school and said he was always friendly, modest and excited to help people. He made a point of always joining his father at Knights of Columbus fundraisers and bingo nights.
"He was amazing," Bedard said. "He was honestly the sweetest kid I ever met. Never said a mean joke."
Bialy smiled as he recounted the struggle with the shooter to reporters, saying that he wanted to focus on the positive. "They completely and utterly failed in a matter of half a minute," he said of the attackers.
"What I saw yesterday was the absolute best of people," he added.
Bialy would not identify the third student who helped subdue the gunman, but the family of Joshua Jones put out a statement saying he was shot twice while disarming one of the attackers.
The security guard who detained the second armed suspect was employed by Boss High Level Protection, a company started by a former SWAT team leader who responded to the Columbine shooting. The owner, Grant Whitus, told The Associated Press the security guard is a former Marine who ran to the area of the shootings and confronted one of the armed students in a hallway.
The guard drew his weapon and apprehended the person, Whitus said.
"He doesn't even realize how many lives he saved by stopping a school shooting," Whitus said.
About 2,000 people held a vigil at a nearby high school Wednesday night to honor the victims and survivors of the attack.
Both suspects were students at the school, and they were not previously known to authorities, Spurlock said.
Erickson made his first court appearance Wednesday and kept his head down. His black hair, streaked with purple dye, covered his face as he nodded in response to most of District Court Judge Theresa Slade's questions. At one point, the judge requested a verbal answer to whether he had any questions about the proceedings. Erickson simply replied "No."
McKinney, who has a short brown haircut, made eye contact with the judge and answered questions in a clear but quiet voice, saying "Yes, your honor" and "No, your honor."
District attorney George Brauchler said he has not decided whether to file adult charges but added that McKinney is old enough to be charged as an adult without a judge's review.
Formal charges were expected to be filed by Friday. Brauchler said he could not discuss any motive or weapons used in the attack.
A message left at a phone number listed for Erickson's home was not immediately returned.
Josh Dutton, 18, said he was close friends with Erickson in middle school but had not seen him for four years while attending a different high school. On Sunday, he spotted Erickson at a local light rail station and said he was shocked at how much his friend had changed.
Erickson wore all black and was significantly thinner and did not seem interested in talking.
"He said he'd just turned 18 and he owned rifles," Dutton said.
The shooting took place exactly a week after a gunman killed two students and wounded four at the University of North Carolina-Charlotte. In that case as well, one of the fatalities was a student who charged the attacker.
The Colorado attack unfolded came nearly three weeks after neighboring Littleton marked the anniversary of the Columbine attack that killed 13 people. The two schools are separated by about 7 miles (11 kilometers) in adjacent communities south of Denver.
Brauchler said the community remains resilient in the face of multiple shootings, including Columbine, the 2012 theater shooting in the Denver suburb of Aurora and the 2013 shooting at Arapahoe High School.
The attacks are "aberrant acts" although they might seem otherwise to the rest of the world, he said. "Who we are is a kind, compassionate, caring people, and this does not define us."
This story has been updated to correct the name of the student who charged the shooter to Joshua Jones, instead of Jason Jones.
Riccardi reported from Denver. Associated Press writers Dan Elliott and Colleen Slevin in Denver and AP researchers Monika Mathur in Washington and Rhonda Shafner in New York contributed to this report.