Dozens of teen-age boys were studying religious texts in a fluorescent-lit hall in this Jewish settlement just before midnight when the buzz-saw rattle of an assault rifle silenced their prayers. 

The bullets ripped through the students' bodies, spraying blood onto walls and white tile floors and shredding ceiling tiles. Blood-smeared prayer books and religious texts were scattered about the hall. Officials said four were killed and 23 wounded in the study hall barrage. 

"We were sitting in the academy praying," one of the students told the Maariv daily. "Suddenly a boy came in ... armed with a long M-16. He looked like a Jew. Suddenly he opened fire and started throwing grenades." 

The gunman, a 19-year-old member of the Islamic militant group Hamas, emptied nine ammunition clips and hurled six grenades into the study hall and a nearby dormitory during his 15-minute rampage before he was gunned down by Israeli troops. 

The assault began at about 11:40 p.m. Thursday. The attacker, identified as Mohammed Farhat from Gaza City, carefully cut through a fence around the settlement, leaving an almost perfect square flap in the metal grid strung with electronic sensors and topped with coils of barbed wire. 

He charged from room to room attacking the students, who were about his same age. He tossed a grenade into one bedroom in a trailer serving as a dormitory, killing a fifth student in his bed and leaving the room a scorched shell of gray ash. The rack of bunk beds was melted down to the metal frames and springs. 

The wounded were airlifted from the settlement by helicopter. After the attack, students stood amid the wreckage, hugging each other. Medics wearing rubber gloves wiped blood and flesh from the rooms to ensure proper Jewish burial. 

About 150 students attend the school, which combines religious studies with military training. Graduates of the one-year course are drafted into top combat units and officer courses. 

A shaken Brig. Gen. Israel Ziv, the Israeli army commander in Gaza, said the slain students were slated to become army officers. "It was horrible, simply horrible," he said. "It shows who we're dealing with, people without any morals, any values, a cruel enemy."