OLIVEHURST, CALIF., MAY 1 -- Four people were killed in a standoff when a disgruntled former student opened fire and took hostages at his old high school today, a sheriff said. The gunman eventually surrendered.

Sheriff Gary Tindel said the dead were a male teacher, two male students and one female. He said they were found in various rooms in the school. Officials did not immediately release the victims' names.

Tindel said Houston, who attended Lindhurst High School in 1988 and 1989, apparently was angry that he failed a class.

"He came back today to vent his frustration and retaliate and shoot people," the sheriff said.

Police said Houston surrendered at 10:29 p.m. Pacific time.

"He gave up. He said nothing when he came downstairs," said Capt. Dennis Moore of the Yuba County Sheriff's Department.

Earlier, authorities also reported at least 10 people wounded, one critically.

Sheriff's officials said the last 20 hostages were freed unharmed.

Sheriff's deputies had surrounded the campus, where about 60 hostages were held initially, Moore said.

Earlier in the evening, 10 of the hostages had been freed in exchange for several pizzas.

Anxious parents had awaited word at a nearby middle school. During the siege, which began about 2 p.m., authorities spoke to the man by telephone.

The gunman, identified as Eric Houston, was unhappy with the treatment he had received when he attended the school, the captain said. Houston entered the building and started firing, witnesses said. He had attended Lindhurst High, but did not graduate.

Student Robert Barbour, 19, a senior, said he saw the gunman shoot a student, then fire into a classroom.

"He just walked in, cocked it, then fired. That was it," Barbour said, adding that he escaped after hiding in a room behind the auditorium stage.

"It was hell, that's all I can say," Barbour said. "I've been shaking all afternoon."

At least 10 people were admitted with gunshot wounds at Rideout Memorial Hospital in nearby Marysville, about 40 miles north of Sacramento, hospital officials said.

One student was listed in critical condition. Two students and an adult were listed in fair condition and four others were reported stable. Condition reports for the others were not available.

Dozens of Yuba County sheriff's deputies had surrounded the school building that houses its library while California Highway Patrol helicopters circled overhead.

The gunman was described as heavily armed, with weapons that included a 12-gauge shotgun.

Witnesses who ran screaming from the school told of multiple injuries.

About four hours after the siege began, about two dozen students had sprinted from the building to safety. Officers said the students had hidden and apparently had not been discovered by the gunman.

Officials said a teacher who had been held escaped and another teacher, who hid from the man, also slipped to safety. The gunman also released two students.

The large number of hostages was a source of consolation for Ray Alvarez, who had thought his 15-year-old daughter Felicia was among them.

"Knowing that there's other kids there, there's some comfort that maybe he won't hurt too many," said Alvarez, waiting outside nearby Yuba Garden School earlier in the evening.

"It's not good. It's emotional sometimes," he said. "But you've just got to keep calm. You let yourself go and it gets worse."

The students who fled the building were taken to the middle school, where some were met by tearful parents.

Officials shared news reports over a public address system. Relieved cries went up as officials read a list of students whose safety was confirmed. The halls were silent when a list of the injured was read.