Three masked gunmen invaded a Chinatown restaurant crowded with about 100 diners early yesterday, assassinated a reputed gang member and then opened fire at random on screaming patrons, killing at least four more and wounding 16, police said.

The gunmen - two with automatic rifles and the third carrying a shotgun - escaped into the night at about 2:40 a.m. PDT after firing at least 20 shots in less than a minute inside the Golden Dragon restaurant on narrow Washington Street in the heart of Chinatown.

Police Chief Charles R. Gain said the shootings stemmed from "a war going on between Chinese gangs" and said the investigation was being hampered by reluctance of witnesses to talk.

Lt. Victor Macia said officers arrived at the scene found people screaming, bodies on the floor and the dining room - on two levels separated by a short flight of stairs - awash with blood.

Police said witnesses reported that as soon as the gunmen entered one approached a male patron sitting at a table and fired a rifle shot into his head. After the man fell to floor, the gunman fired two more shots at him, police said, then all three gunmen began firing at random.

Officer Terence Collins said the man who was the apparent target of the attack "was known to be with one of the Chinese gangs in San Francisco."

Police report 39 gang-related slayings in Chinatown since 1969.