A former Lake Braddock Secondary School student, apparently despondent because his girlfriend, a student there, had spurned his offer of marriage, returned to his old school yesterday with a high-powered rifle and took nine hostages, firing several shots in the process.

Two of the hostages were released after almost six hours, about 7 p.m., after police offered the gunman a cup of coffee, and three more were freed by early today. Fairfax County police said they were optimistic that the crisis could be resolved, but declined to predict whether negotiations could be completed in time for school to reopen this morning. "Time is on our side," said Fairfax County Police Chief Carroll D. Buracker.

Police identified the gunman as James Stevens, 18, a former student at the school, and said that Stevens had demanded a gallon of vanilla ice cream, a pizza and two Pepsi Colas from police negotiators while holding the school's principal hostage.

One of the released hostages was hospitalized briefly, apparently suffering from fatigue, but no injuries had been reported.

Police spokesman Andrew Page said Stevens was "trying to get himself out of a bad situation. It's an emotional situation over a conflict he had with a girlfriend."

Early in the afternoon police evacuated the school's 4,300 students through side and rear exits as officers and the young man's stepfather, Fairfax police officer John Isom, began telephone talks with Stevens. Friends and neighbors said Stevens had dropped out of the school's senior class last year and was working at a clothing store in the nearby Ravensworth area while attending night school.

There were conflicting accounts last night of how the incident began. Fairfax police spokesman Warren Carmichael said Stevens and his girlfriend were talking in the school's front yard about 1 p.m. when the girl was summoned to an office by a public address system. When she turned to go, Carmichael said, Stevens fired a shot in her direction. The girl then ran off, Carmichael said, and Stevens bolted into the school's adminstrative office.

According to students, Stevens had gone to the school, demanding to see the girl who had rejected his offer of marriage the night before. School officials summoned the girl to an office over the loudspeaker and a few moments later, students said, she dashed from the room.

"I heard a shot and she came running out screaming, 'He's got a gun,' " said student Tim Bottrell, who was in a nearby school clinic.

Up to half a dozen shots were fired, at least two at police, according to witnesses, but there were no reported injuries as of late last night. Police said Stevens was holding Lake Braddock principal John Alwood hostage, as well as three other adults, believed to be faculty, clerical or data-processing employes.

Police said they believed the gunman fired about four shots into the ceiling or walls, and said he had also fired twice at a police officer who was trying to enter the school through the front door. Chris Spring, a 16-year-old student, was on his way to his locker when he heard a shot ring out. "I told you to get out of here," Spring said the gunman shouted.

Other shots sprayed through a window toward the school parking lot, prompting police to bar teachers and students from moving their cars.

According to Buracker, Stevens had been holding Principal Alwood at gunpoint for several hours before he became aware of the presence of eight other people, who were cornered in an adjacent office that had no other exit. Early in the evening, Buracker said negotiators described Stevens as being highly emotional. "There is some indication that he wants to run out in the hallway and force officers to shoot," he said. A few hours later he reported that the gunman was "calmer than he was before."

"It's a very scary situation," said Elizabeth Alwood, the principal's wife, as she listened to radio news reports at home with her 16-year-old daughter Kristen. "I feel a little better knowing that the boy's motive was not to harm my husband but to get back with his girlfriend."

Stevens and the girl had been dating a long time, according to the girl's sobbing 15-year-old sister, who joined the crowds of anxious students waiting outside the school grounds. She said her sister had rejected a marriage proposal Tuesday night from Stevens and the two had parted angrily.

Stevens apparently entered the grounds of the school, the largest one in Fairfax County, with the rifle in clear view. Some witnesses said it had a telescopic sight. "A couple people saw him coming in with the gun, but they didn't think anything of it," said Walt Mika, a social studies teacher. "They thought it was a prop for a play. They're doing 'Oklahoma.' "

As Fairfax police surrounded the school and sealed off the classrooms from the administrative office area, school officials went from room to room, telling teachers of the trouble and advising them to keep students in their places. The students remained in their classrooms for more than two hours, until they could be led out back doors of the building and onto 50 waiting yellow school buses. Students who lived within walking distance were taken from the school in police vehicles.

Some teachers said they told their students what was developing in the school's front offices, while other teachers said they didn't want to alarm students and chose not to tell them.

Police said that Stevens released two women, identified only as Toni Crumm, a school aide, and Frances Churchman, a student's parent, shortly after 7 p.m., when officers brought him coffee. A teacher, Peggy Rydenn, was released about 8:30 p.m., and another school employe, Carol Pogharin, was freed shortly afterward. June Harrison, a 57-year-old finance officer, was released about 11 p.m. and taken to Commonwealth Hospital, apparently suffering from fatigue. She was discharged at 1:05 a.m.

Students, neighbors and former classmates described Stevens as a quiet, likable, good-looking youth who is known as "Jamie" by his friends. "He's a very friendly guy," said Sharon Kline, a recent Lake Braddock graduate who said she has known Stevens for more than four years. "He's very easy-going."

A special police team and negotiators continued talking to the gunman by telephone yesterday evening. The girlfriend and her parents were also summoned to the school to assist, police said. "We're not sure what he wants," said Buracker. "He's been on the phone with negotiators trying to resolve things between himself and his girlfriend.''