A teenager who may have had a grudge against a teacher opened fire with a shotgun at a Colorado high school, wounding two students before killing himself.

Quick-thinking students at Arapahoe High School on Friday alerted the targeted teacher, who quickly left the building.

The scene unfolded on the eve of the Newtown massacre anniversary, a sombre reminder of the ever-present potential for violence in the nation’s schools.

One of the wounded students, a girl, was hospitalised in serious condition. The other student suffered minor gunshot-related injuries and was released from the hospital hours later, authorities said.

A third person was being treated for unspecified injuries but had not been shot, a hospital spokeswoman said.

Arapahoe County Sheriff Grayson Robinson initially reported that the most seriously hurt student was wounded after confronting the gunman, but he later said that did not appear to be the case.

Robinson identified the shooter on Friday night as Karl Halverson Pierson.

The shooter entered the school armed with a shotgun and looking for a teacher he identified by name, said Mr. Robinson.

The teacher immediately left the school when he learned the student was looking for him, Mr. Robinson said.

“He knew he was the target and he left that school in an effort to try to encourage the shooter to also leave the school,” the sheriff said. “That was a very wise tactical decision.”

Two suspected Molotov cocktails were also found inside the school, the sheriff said. One detonated, though no one was injured.

Within 20 minutes of the first report of a gunman, officers found the suspect’s body inside the school, Mr. Robinson said.

Students were seen walking toward the school’s running track with their hands in the air, and television footage showed students being patted down. Mr. Robinson said deputies wanted to make sure there were no other conspirators.

Authorities later concluded that the gunman had acted alone.

Nearby neighbourhoods were jammed with cars as parents sought out their children. Some parents stood in long lines at a church. One young girl who was barefoot embraced her parents, and the family began to cry.

Several other Denver-area school districts went into lockdown as reports of the shooting spread. Police as far away as Fort Collins, about a two-hour drive north, stepped up school security.

More In: World | International | News