NEW YORK, OCT. 19 -- Bernhard H. Goetz was sentenced today to six months in prison for illegal weapons possession, in the final chapter of the 1984 subway shooting that ignited a worldwide debate about urban violence and vigilantism.

Goetz, 39, an electrical engineer, stared grimly at the floor as acting Manhattan Supreme Court Justice Stephen G. Crane imposed sentence. Goetz, who could have received up to seven years in prison, also was fined $5,000, ordered to undergo psychiatric treatment, placed on five years' probation and directed to perform 280 hours of community service.

Goetz did not speak on his own behalf and was allowed to remain free pending appeal.

Today's proceedings were the final echo of the shots from Goetz's .38-caliber revolver on Dec. 22, 1984, when he shot and wounded four black youths on an IRT subway car after one of them had asked him for $5. After a seven-week trial, Goetz was acquitted in June of attempted murder charges but convicted of third-degree possession of an illegal weapon.

Minutes after the sentencing, the Rev. Al Sharpton, a black leader here, told reporters he hoped the sentence "will send a signal that white vigilantism is not going to be excused . . . . But if Bernie Goetz had been black, he would have gotten much more than six months."

Crane said he was concerned with "deterrence" and that "a non-jail sentence for Mr. Goetz would invite others to violate the gun laws." He said that Goetz has owned guns illegally since 1970 and "used a quick-draw holster and ammunition designed to maximize physical injury."

The judge also noted that Goetz had tried to buy another gun in Florida after his indictment for the 1984 shootings. He said that half of all persons without previous criminal records who are sentenced on such charges in Manhattan are not incarcerated but that the state legislature has urged a minimum one-year jail term be imposed in most cases.

Earlier, Manhattan Assistant District Attorney Gregory Waples said there was a huge gap between the "myth" of Goetz as "an innocent victim of life in New York" and "the sad reality that this defendant is a sick man . . . . Far from being totally harmless, this defendant, in my estimation, is dangerous." Waples' office had recommended a "substantial sentence" for Goetz.

Goetz's lawyer, Barry I. Slotnick, told the judge that Goetz has endured "three years of pain and suffering . . . . Sending him to jail would be unfair and unjust . . . . This man has been victimized." He said Goetz has been a prisoner in his apartment because of the intense media attention and plans to leave New York.

A report by the city's probation department recommended that Goetz receive psychiatric treatment instead of a prison sentence.

Goetz has become a hero to many in this crime-weary city, a slender, bespectacled symbol of the man who fights back in a dangerous situation. But others view him as a dangerous gunslinger who took the law into his hands. Goetz has said he repeatedly tried to obtain a gun permit after being badly beaten in a 1981 mugging.

After surrendering in the subway shooting, Goetz described in a videotaped confession how he walked over to one of the youths and said, "You seem to be all right, here's another," before firing a second shot.

The youth, Darrell Cabey, now 21, remains paralyzed and brain damaged from the shooting. Two of the others are in prison: James Ramseur for sodomizing a pregnant woman and Barry Allen for a probation violation. The fourth, Troy Canty, is in a drug rehabilitation program.

Lawyers for Cabey, William Kunstler and C. Vernon Mason, had urged incarceration for Goetz, calling him "a vicious and unstable overt racist" who would "shoot to kill once more."