(CNN) -- A North Dakota freshman walked in front of his class, made an apology and then shot himself with a handgun Thursday morning, Richland County authorities said.
The injured boy was coherent when he was taken to a hospital, said Principal Jay Townsend of Fairmount Public School, which has 112 students from kindergarten through 12th grade.
Authorities don't know what the apology was about, Sheriff Larry Leshovsky said.
The student wasn't in any kind of trouble that the principal was aware of.
The freshman, whose name wasn't being released, has lived in the small, rural community of 380 residents his entire life and has spent all educational years at Fairmount School, Mayor Jon Nelk said.
The student was transferred to a hospital in Fargo, but the mayor had no further details.
The student's grandparents grew up in the Fairmount area and his parents have lived in town their entire lives, Nelk said.
"As far as I know, he's a well-behaved, good kid," the mayor said. "We're a rural area, but guns are not commonplace."
The shooting was "an isolated incident" for the town, Nelk said.
"I'm sure when we sit down this evening and start playing it back, we'll try to figure out what could have possibly happened and why this happened," Nelk said. "It's a very tight community.
"I've had a lot of conversations with parents and some students. They're quite worried and hoping that our prayers go out to the child and the family and the friends," the mayor said.
A teacher provided first-aid to the boy, and the school went into lockdown shortly after the 8:40 a.m. shooting, Townsend said.
An alert system called all parents, and school was canceled for the day, Townsend said.
School will resume Friday, when counselors will be on hand, the principal said.
"This has never happened here before," said Townsend, who has been principal of the school for five years. "This kind of situation is very rare and new to North Dakota, the community, our school and the students."