SAN FRANCISCO (AP) _ The father of a slain teen-age girl smuggled a revolver into a courtroom in a hollowed-out book and fired point-blank at the accused killer, wounding him as the judge dived under the bench, witnesses said.

Jack Spiegelman had been watching pretrial proceedings Thursday when he suddenly rose, pulled a pistol from his pocket and aimed it at the defendant, Daniel David Morgan, who was about six feet away, the witnesses said.

''Jack had a gun in his hand, leaned over the railing and held it in both hands and fired,'' said Assistant District Attorney Thomas Norman, who was prosecuting.

Superior Court Judge William D. Stein said he was taking notes on the testimony when Spiegelman fired.

''I looked up and saw a man standing there with a gun in his hand. I heard one or two shots, and I went down under the bench,'' Stein said. ''Then I heard some more shots, and I looked up, and the defendent was lying on the floor.''

Morgan, 39, was shot three times in the right arm, and the fourth shot grazed his scalp, said Sheriff's Department spokesman Ray Towbis. A spokeswoman at San Francisco General Hospital said Morgan was in satisfactory condition late Thursday after two hours of surgery.

After the shooting, Spiegelman dropped the gun and surrendered, said police Inspector Jeff Brosch, who was testifying at the hearing.

Spiegelman, 47, a Los Angeles accountant, smuggled the gun into the courtroom in a hollowed-out book, said police Inspector Manuel Barretta. He was booked on charges of suspicion of assault with intent to commit murder and carrying a concealed firearm. No bail was set, Barretta said.

Morgan is charged with murdering Spiegelman's 17-year-old daughter, Sarah, who was shot with a companion, 26-year-old Dwion Gates, on March 6, 1983, as they sat in Golden Gate Park. She died of a bullet wound to the head. Gates, who until recently needed crutches to walk, said a bullet still remains lodged near his spine.

Officials have said they believed the shooting was racially motivated because Miss Spiegelman was white and Gates is black.

Asked about courtroom security, Stein said, ''Obviously we are going to have to do something, but it's hard to stop anyone who is intent on killing.''

Spiegelman is an active member of Parents of Murdered Children, a Southern California-based group, and another group, Justice for Homicide Victims.

''He was a very upset, very angry person,'' said Marcella Leech, editor of the Justice for Homicide Victims newsletter. She said Spiegelman told friends recently that his life was ruined because of his daughter's slaying.

Ms. Leech said she recalled him saying that murderers can get probation, but survivors serve a life sentence of grief. He also said he worried that Morgan would be judged unfit to stand trial, Ms. Leech said.

In July 1983, a San Francisco judge ruled that Morgan was mentally incompetent to stand trial. The following month, he was ordered admitted to Atascadero State Hospital for the criminally insane.

A year later, he was ordered returned to San Francisco County for prosecution after he was found competent to stand trial.