A student at a high school near Charlotte, N.C., fatally shot a schoolmate on Monday morning during a fight before classes began, sending dozens of horrified students fleeing for safety, the authorities said.

Officials said that bullying that had “escalated out of control” had led to the fatal encounter at David W. Butler High School in Matthews, N.C., but would not say who had done the bullying.

“What took place this morning is something that built up,” said Capt. Stason Tyrrell, a patrol commander for the Matthews Police Department, at a news conference. “Several people knew about it — not knew there was going to be a shooting, but knew there was going to be a likelihood of some sort of altercation this morning.”

The police said that Jatwan Craig Cuffie, 16, a ninth grader at the school, was fighting with Bobby McKeithen, 16, a sophomore, in a hallway after 7 a.m., when Mr. Cuffie shot Mr. McKeithen. They did not say what kind of gun was used or how many times Mr. McKeithen was shot.