Updated

A 12-year-old student opened fire inside Tuesday inside the gym at a New Mexico middle school in front of 500 fellow students, injuring two classmates, one critically, before a teacher talked him into dropping his weapon, authorities said.

The shooting erupted at 8:11 a.m. as students were dropped off to begin the day at Berrendo Middle School in Roswell. It was not immediately clear what provoked the shooting.

New Mexico Gov. Susana Martinez said late Tuesday that the boy wounded in the shooting underwent two surgeries. Sources tell Fox News that the boy was 11 years old and was shot in the face and upper chest. A 13-year-old girl who was also wounded is now in stable condition, the governor said.

A staff member who was also injured refused medical attention, police said.

Martinez said the boy pointed the gun at a teacher, who talked him into dropping the weapon. The boy was taken into custody.

"It was a harrowing experience," John Masterson, who was identified as the teacher who talked the suspect into putting down the gun, told The Albuquerque Journal. “All I can say was the staff there did a great job.”

Martinez asked that fellow New Mexicans keep the victims in their prayers.

The suspected shooter, whom authorities identified as a 12-year-old seventh-grader armed with a shotgun, was taken into custody after he was confronted by a staff member and an off-duty police officer who was dropping off his child at the school, police said.

He was transferred to an Albuquerque psychiatric hospital following a hearing Tuesday, according to attorney Robert Gorence, who is representing his family. Gorence said the family will release a statement Wednesday.

New Mexico State Police Chief Pete Kassetas said late Tuesday that the shooter used a 20-gauge shotgun. The Albuquerque Journal reported that the suspect allegedly sawed off the gun's wood stock, put it in the bag and snuck it into school.

He said they're investigating where he got the gun and have issued search warrants for the boy's home and his bag and locker.

Authorities said the boy sneaked the shotgun onto campus through a bag or musical instrument case.

Kassetas disputed a report from a hospital spokesman who said nurses treating the boy indicated he was the shooter's target. He said a motive still is not known.

"We just don't have a lot of information," Kassetas told reporters late Tuesday.

Sixth-grade student Anyssa Vegara said she was talking to a security guard when she heard a shot. "I turned around, and all I saw was someone on the floor with their arm bleeding," Vegara told The Albuquerque Journal.

She said the security guard ran to assist the injured student, and school officials ordered all the students to their classrooms.

Eventually, she was able to text her mother, Monica Vegara.

"From the time hearing about it until the time she texted, it was a nightmare," Monica Vegara said.

"I just saw blood everywhere," Essance Sosa, 12, said Tuesday. "Everyone started screaming and running."

Fawna Hendricks, whose son is a seventh-grader at the school, told the newspaper she heard about the shooting on the radio. "Basically I jumped outta bed, threw on clothes and panicked," Hendricks said.

On Tuesday night, hundreds of people poured into the Roswell Civic Center for a prayer vigil, including elected officials and law enforcement officers from various agencies. There were many hugs and tears.

"We really need this," Roswell resident Maria Lucero, 35, said of the vigil. "We need to pray for the families of the victims and the little boy that did the shooting. I'm going to pray for them all."

Eighth-grader Odiee Carranza said she was walking to the school gym when the shooter bumped into her as he rushed past. She told him to be careful, and he apologized and continued on. The boy ran to the gym, where he pulled a gun from a band instrument case and fired at the students.

"Then he shot up in the sky, then dropped the gun, and then some teacher grabbed the kid that had the gun," Carranza said.

Carranza described the shooter as a "smart kid and a nice kid."

In the hours after the shooting, social media sites were flooded with sentiments offering prayers for the community. Some Berrendo students posted on their Facebook pages that they were frightened and didn't want to return to classes.

"I'm still scared to go back to school," Carranza said.

Roswell has a population of about 50,000. It is a center for ranching and farming, and is home to the New Mexico Military Institute, the only state-supported military college in the West.

The Associated Press contributed to this report.