After the shooting stopped at Reynolds High in Troutdale, near the city of Portland, Oregon, police spotted the suspect in a toilet.
Officers used a robotic camera to investigate and discovered the suspect was dead, and that he had likely killed himself, said Troutdale police spokesman Sergeant Carey Kaer.
His victim was identified as freshman Emilio Hoffman, who was "loved by all," police chief Scott Anderson said. He said Emilio, who police believe was shot at random, was found in the boys' locker room.
The violence took place less than a week after a gunman opened fire on a college campus in neighbouring Washington state, killing a 19-year-old man and wounding two others.
It follows a string of mass shootings that have disturbed the nation, including one on Sunday in Nevada that left two Las Vegas police officers and a civilian dead.