The student shot John Klang, 49, when confronted, before being subdued by a teacher and other students until police took him into custody. No others were hurt.
Mr Klang, 49, who oversees the Weston school district near Cazenovia, was shot three times and died in hospital, authorities said.
Police said a janitor wrested away the shotgun from the boy who then pulled out a handgun when confronted by Mr Klang, firing and striking the principal in the leg, chest and head.
"The heroics of people can never be overestimated," Sauk County Sheriff Randy Stammen said, calling Klang "a truly wonderful person".
"At this time it would appear he acted independently," Sauk County District Attorney Patricia Barrett said of the gunman.
"He did not disclose his plans to anybody else," she said, though the boy had confided to a friend at least two days earlier "that he didn't believe Mr Klang would make it through homecoming".
Ms Barrett says the suspect would be charged with murder and faces a maximum penalty of life in prison.
One student said he ventured into a school hallway and saw the suspect toting a shotgun. The student retreated into a classroom, hearing the gunman say, "you better run:"
Colorado killing
Meanwhile, Colorado authorities have offered scant details from a 14 page handwritten letter from a drifter who on Wednesday took six female high school students hostage, molested them and then shot one to death and killed himself as police closed in.
In the letter to a relative mailed the day of the assault, Duane Morrison discussed his pending death and apologised for his actions in advance, though he did not spell out his intentions or mention the school he invaded.
Morrison shot 16-year-old Emily Keyes in the head before shooting himself as officers entered. The last remaining hostage ran to safety.
One of the girls in the classroom, Lynna Long, told the Rocky Mountain News Morrison focused on Keyes when he walked into her honours class with a gun and a backpack he said contained a bomb.
He ordered the male students to leave and made the girls stand facing a wall before groping them one by one. "He paid special attention to Emily, I don't know why," Ms Long told the newspaper.
She heard Keyes saying, "No, please don't".
Ms Long said that while she was forced to stare at the wall, the other girls were being molested because, "You could hear the rustling of clothes and elastic being snapped and zippers being opened and closed".
