GAZA CITY -- It was just another demonstration in the occupied Gaza Strip, where protest is a way of life. Students poured out of the Palestine Secondary School last March in honor of the 30th anniversary of Israel's withdrawal from Gaza after the Suez crisis and headed up a main road to link up with students from another school. Israeli soldiers arrived, and dozens were rounded up.

Samer Zaket, 16, and Diya Hanawi, 15, were among them. They were sentenced by a military court to two months for inciting a riot and taken to the makeshift detention center near the coast here known by residents as Ansar II. It was the first time either youth had been away from home.

When they got there, they said, they were crammed into a damp, chilly prison cell with about 30 other Palestinians, ranging in age from 12 to 24. The food was bad, the mattresses dirty and the treatment by some Israeli guards, they contend, was harsh. The youths were terrified of what would happen to them.

They learned many lessons in Ansar II. After a few weeks together, the prisoners staged a four-day hunger strike for more blankets and better food, and they got to know one another in the intense way that people do when tough circumstances bring them together. When they came out last May, they found they were considered heroes by their classmates and neighbors, "graduates" whose time in prison won them respect and admiration.

"The first two days I was so scared, but the other boys supported me," Zaket recalled. "But by the time we got out, we were much more nationalistic than when we went in."

Citing fear of arrest, neither teen-ager talked about his involvement in last month's disturbances that struck here and in the West Bank, resulting in at least 22 Palestinian deaths and about 1,000 arrests. But those who have sought to analyze the riots -- including Israeli military officials, western diplomats and Palestinians themselves -- believe that it was youths such as these, ranging in age from 15 to 25, who were the street warriors.

The hard-core leadership in Gaza, many contend, consisted of about 150 to 200 young men, all of them recent graduates of Ansar II. Once the riots started with a spontaneous outburst in Gaza, the radicals helped keep them going by organizing demonstrations and enforcing a general strike by shopowners and workers. Some even traveled to East Jerusalem to help organize the Dec. 19 outburst of rioting there, Israeli Army officials said.

What happened to Zaket and Hanawi at Ansar II has happened to hundreds, even thousands, of other Palestinian youths in recent years. The process of radicalization begins on the streets and in the schools, but for many it is the first run-in with Israeli troops and military justice that is the crucial moment that changes angry young men into determined fighters.

"You put in stone throwers and they come out grenade throwers," said Hirsh Goodman, veteran military commentator of The Jerusalem Post. "The prison experience is definitely something that doesn't deter them. They come back to school wearing it like a badge of honor."

"It is a new generation of people born since the occupation began 20 years ago, and they dominate the streets," said Zuheir Rayyes, a Gazan author and journalist closely identified with the outlawed Palestine Liberation Organization. "They're not afraid of the Israelis. They don't worry about aircraft or missiles. They are very well-organized, and they have a very simple weapon -- the stone."

Their "finishing school" is a collection of box-shaped gray buildings and Army tents located on a collection of sand dunes behind razor wire, electrical fences and guard towers near the seashore. There is no sign at the gate. The Army officially calls it the "Beach Installation." But to both sides it is known by the nickname Ansar II.

The original Ansar was a temporary detention facility in southern Lebanon where hundreds of Palestinian fighters were held captive during the Israeli invasion of Lebanon. The nickname, residents say, emphasizes the link between Gazans and their Palestinian brothers in Lebanon and their common enemy: Israel.

Ansar II is a special detention center. Unlike most of the military prisons in the West Bank and Gaza, it is operated not by Israel's prison service, but by the Army and its military police.

Palestinians and their lawyers say conditions there are miserable. Doctors at nearby Shifa Hospital say they receive patients daily from Ansar II with broken or bruised limbs or other injuries they contend were inflicted by prison guards. Israeli lawyer Felicia Langer has petitioned the Israeli Supreme Court to release eight of her clients on the grounds that they have been tortured or otherwise abused at Ansar II.

Senior Army officials have pledged that Palestinian prisoners in West Bank prisons would receive correct treatment in adequate facilities, but have maintained public silence about conditions in Gaza. Asked about conditions at Ansar II, a military spokesman replied last week that the office of the Army's Judge Advocate General, Brig. Gen. Amnon Strasnov, "will be conducting a thorough investigation of the jail next week, and I am really not at liberty to give you further details right now.

"The objective is that conditions in such facilities would be equal to conditions in other military jails and in jails inside Israel itself," he said. "Whether or not this is the case we do not know, but this is the objective."

It was not possible to verify independently any of the charges of Palestinians about conditions at Ansar II, and the Army has not allowed reporters to tour the facility. But it is clear that the prison's reputation stirs deep fears in Gaza.

Prisoners rounded up during the past two weeks who were brought to military courts for trial often appeared demoralized and trembling, and some seemed close to tears. Most of them were first-time offenders getting their first taste of confinement; for many, it was also their first contact with Israelis.

But the fear is a temporary phenomenon, according to some Ansar II graduates. "What happens is that before someone is in prison, he hears about the terrible things that happen in Ansar II, and he is afraid," said Hijazi Burbar, who spent three days in the facility in October. "But after he goes in and sees it, the fear goes out of him, and experience shows he is more willing to fight and do something."

Burbar is a 30-year-old prayer leader at the El Katiba mosque here, who wears a beard and the gray, flowing robe of an imam. He is considered to be in the forefront of the Islamic revival movement, which has joined forces with secular Palestinian nationalists in recent months and presented a united front against the Israeli occupation.

By his own count he has been arrested 14 times over the past decade and has seen the inside of more than six Israeli detention centers, including those in Ashkelon, Ramle and Kfar Yonah, and the central prison in Gaza. Ansar II, he says, is the worst.

He, too, shared a prison cell with 30 to 35 inmates who slept on the floor on dirty mattresses. Each prisoner had to share a mattress with one and sometimes two other people. "We went to sleep like sardines in a can, one right on top of the other," Burbar recalled.

There was no running water in the cell and no toilet. Prisoners were given tin cans to relieve themselves and once each day were allowed to use toilet facilities outside. They were often required to run to and from the toilet, he said, and sometimes beaten when they did not move quickly enough.

On one occasion, Burbar said, when prisoners refused to stand up for the daily count, guards fired a tear-gas canister into the cell. He said he was accused of helping to instigate the rebellion and was beaten by guards and placed in a one-yard-square isolation cell for four hours with his hands tied behind his back and his legs in chains. He finally was taken to a medical facility because of an injury to his leg that he said still plagues him.

Burbar said prisoners quickly organize themselves at Ansar II and develop their own leaders and rules. Different political groups -- communists, followers of Fatah, the PLO's main wing, and supporters of Islamic Jihad, the fundamentalist movement -- have their own leaders, but all work together to oppose the prison administration.

"It's like a melting pot," he said. "Someone who throws a stone and gets put in jail often has no connection with any particular leadership or movement. He enters jail, and he becomes part of the system. They teach him about culture, about politics, about relations between people, and after two or three months he comes out more of a danger to the occupation than he was when he went in."

Burbar said he sees himself and his views as a product, in part, of the prison system. "Every time I get out after I am arrested, I am more willing to do {illegal} things than I was before," he said.

Samer Zaket said that the first time he was taken before a military court for arraignment he and his fellow prisoners were frightened, but that the second time they sang Palestinian songs in the prison van.

His friend Diya Hanawi said the most important thing he learned at Ansar II was patience. "The life is hard, the food isn't good and there's no soap, and you're away from your family," he said. Asked how he felt about his Israeli guards, he replied, "How do you think I should feel when someone arrests me and puts me in that situation?"

Zaket is not as angry as his friend, Hanawi. "They were like any other people," he said of the Israelis. "There were some who treated us well and some who treated us very badly."

The two friends are middle-class Gazans. Zaket's father is an elementary school principal, while Hanawi's works as a clerk for the occupation adminsistration. One teen-ager wants to be a lawyer, the other an engineer. But now that their names are on a list of those with Palestinian political convictions, they said they believe that they will not be granted travel documents to study abroad. Their own futures have become inextricably bound to the future of the Gaza Strip.

The Israeli Army says it is aware of the impact that Ansar II has on young Gazans but that the military lacks alternatives. Goodman of The Jerusalem Post said that for a while the Army tried to impose heavy fines instead of jail sentences on first-time offenders, but found that the fines were paid by the PLO.

In the West Bank, the Army opened a special facility for youthful offenders near Al Faraa, but soon found that, even when segregated from older, hardened prisoners, the youths developed a political culture and organization of their own.

"We know we obviously have a problem, but we're damned if we do and damned if we don't," said the Army spokesman.