A 20-year-old man wearing combat gear and armed with semiautomatic pistols and a semiautomatic rifle killed 26 people — 20 of them children — in an attack in an elementary school in central Connecticut on Friday. Witnesses and officials described a horrific scene as the gunman, with brutal efficiency, chose his victims in two classrooms while other students dove under desks and hid in closets.

Hundreds of terrified parents arrived as their sobbing children were led out of the Sandy Hook Elementary School in a wooded corner of Newtown, Conn. By then, all of the victims had been shot and most were dead, and the gunman, identified as Adam Lanza, had committed suicide. The children killed were said to be 5 to 10 years old.

A 28th person, found dead in a house in the town, was also believed to have been shot by Mr. Lanza. That victim, one law enforcement official said, was Mr. Lanza’s mother, Nancy Lanza, who was initially reported to be a teacher at the school. She apparently owned the guns he used.

Although reports at the time indicated that the principal of the school let Mr. Lanza in because she recognized him, his mother did not work at the school, and he shot his way in, defeating a security system requiring visitors to be buzzed in. Moments later, the principal was shot dead when she went to investigate the sound of gunshots. The school psychologist was also among those who died.

The rampage, coming less than two weeks before Christmas, was the nation’s second-deadliest school shooting, exceeded only by the 2007 Virginia Tech massacre, in which a gunman killed 32 people and then himself.

Law enforcement officials said Mr. Lanza had grown up in Newtown, and he was remembered by high school classmates as smart, introverted and nervous. They said he had gone out of his way not to attract attention when he was younger.

The gunman was chillingly accurate. A spokesman for the State Police said he left only one wounded survivor at the school. All the others hit by the barrage of bullets from the guns Mr. Lanza carried died, suggesting that they were shot at point-blank range. One law enforcement official said the shootings occurred in two classrooms in a section of the single-story Sandy Hook Elementary School.

Some who were there said the shooting occurred during morning announcements, and the initial shots could be heard over the school’s public address system. The bodies of those killed were still in the school as of 10 p.m. Friday.