The shooting Friday came a day after the principal gave 15-year-old Eric Hainstock a disciplinary warning for having tobacco, according to a criminal complaint.
Hainstock was taken into custody and charged as an adult with murder, the district attorney said. He could get life in prison if convicted.
Detectives searched Hainstock's house late Friday, the sheriff said. The teen was scheduled to make an initial court appearance Monday. It was unclear whether he had an attorney.
On Friday morning, Hainstock pried open his family's gun cabinet, took out a shotgun, retrieved the key to his parents' locked bedroom and took a .22-caliber revolver, according to a criminal complaint.
He entered Weston Schools with the shotgun before classes began and pointed the gun at a social studies teacher, but custodian Dave Thompson wrested it from the teen, the complaint said. When Hainstock reached for the handgun, Thompson and the teacher ran for cover.
Principal John Klang confronted Hainstock. A teacher said that after the shots were fired, Klang, already wounded, managed to wrestle the shooter to the ground and sweep away the gun, the complaint said. Students and staff detained Hainstock until police arrived, District Attorney Patricia Barrett said.
No one else was injured. Klang, 49, was shot in the head, chest and leg, authorities said.. An autopsy was scheduled for Saturday.
Sheriff Randy Stammen praised Klang's swift action. "The heroics of the people involved in this can't be understated," he said.
School officials said Klang had given Hainstock a disciplinary notice Thursday for bringing tobacco to school, and the student faced a likely in-school suspension, the complaint said.
Hainstock told investigators a group of children had called him names and rubbed up against him, and he felt teachers and the principal would not do anything about it, according to the complaint.
It also said Hainstock had told a friend a few days earlier that Klang would not "make it through homecoming," referring to festivities planned for the school's homecoming weekend.
After the shooting, Weston's football game, dance and parade were canceled or postponed, and crisis counselors were brought in for students.
Children from pre-kindergarten to the age of 18 attend the small school near Cazenovia, a community of about 300 people about 70 miles northwest of Madison.
Sophomore Shelly Rupp, 16, said she woke up ready to celebrate homecoming. Instead, she ended up catching a glimpse of her principal lying in the hallway in "a pile of blood."
"He was really nice," she said, choking back tears. "If we had a problem he'd listen to us. He never raised his voice or anything to any of the students."
Klang and his three children graduated from Weston Schools. Klang taught, then farmed for about 18 years before returning to teaching and taking over as principal in 2004, said his father, Don Klang. He was being groomed to become superintendent next year.
The shooting took place two days after a gunmanin a Colorado high school and killed one before shooting himself.