A boy was critically injured and a girl was in satisfactory condition following the shooting at Berrendo Middle School in Roswell.
Gov. Susana Martinez said the students were in the gym, where they typically hang out before classes start during cold and inclement weather. The 12-year-old opened fire with the shotgun there at about 8 a.m.
However, he was "quickly stopped by one staff member who walked right up to him and asked him to set down the firearm, which he did," Martinez said at a news conference.
Superintendent Tom Burris said the school's faculty had participated in "active shooter" training, and they responded appropriately Tuesday.
"In the 10 seconds that transpired from the time of this thing starting until the teacher had control of the weapon, there was no cowardice," Burris said. "There was protection for our kids. Everyone acted and did their duties today at Berrendo Middle School."
Officials at University Medical Center in Lubbock, Texas, said an 11-year-old boy was flown there in critical condition and a 13-year-old girl arrived in serious condition. Her condition was upgraded to satisfactory Tuesday evening.
Information from nurses treating the boy indicates he was the shooter's target, hospital spokesman Eric Finley said. There was some confusion about the boy's age, but Finley said his parents told the hospital he is 11.
The governor said a staff member received very minor injuries but declined medical care because he wanted to stay and help.
The suspected shooter, whom police have not named, 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.
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."
Student Gabby Vasquez said the boy who was shot "was really nice, got along with everybody."
State Police Chief Pete Kassetas said the investigation was in the early stages, and authorities were still looking into a possible motive. He estimated more than 100 students and faculty members needed to be interviewed.
"I don't have a lot of answers as of yet," Kassetas said, adding police believe they have the only individual responsible for the shooting in custody. The suspect's name was not released.
"I want to make sure the community knows there's really nobody else out there," Kassetas said.
A statement from the state police said authorities responded at 8:11 a.m. The school was placed on lockdown and children were bused to a nearby mall, where parents picked them up.
At the mall, parents waited anxiously. Some held hands, while others hugged each other.
Classes were later canceled and won't resume until Thursday.
Two prayer services were scheduled for Tuesday night at Roswell's Calvary Baptist and First Baptist churches. Pastor Chris Mullennix of Calvary Baptist said parents were worried and heartbroken, but there was a sense among many he spoke with that the community would be able to come together.
"This is something that strikes people to the core," he told The Associated Press. "We're not talking about a flesh wound or just a mental wound. We're talking about the very souls of people being shaken and rocked by something like this."
Mullennix said the prayer services will start the healing process.
"This is tragic but yet people in Roswell are tough, and people in Roswell will recover because we do have a sense of community, and I think that's really important," he said.
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 city is perhaps best-known as the site of an alleged UFO crash in 1947.