The injured boy was coherent when he was taken to a hospital, said Principal Jay Townsend of Fairmont 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.
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."