Masked gunmen armed with automatic weapons and hand grenades burst onto the grounds of the Islamic University here today and in a wild shooting spree killed three Palestinian Arabs and injured 33 others.

The attack, one of the worst incidents of violence in the Israeli-occupied West Bank in recent years, set off Arab protests later today in the West Bank city of Nablus, where one Arab woman was killed and another wounded. There were no official reports on who was responsible for the Nablus shootings. Israeli officials said soldiers opened fire in the city following incidents of stone-throwing by Arab youths.

Some Israeli officials suggested that the Hebron shooting may have been an outgrowth of tension in the West Bank between Islamic fundamentalists and Palestinian nationalists. But most initial suspicion, also reflected in the private comments of Israeli officials, was directed at the militant Jewish settlers of Qiryat Arba, a large settlement next to Hebron, who are seeking to expand the small Jewish presence inside the city.

Israeli authorities imposed curfews in Nablus, Hebron and the town of Halhoul, which is just north of Hebron, and poured hundreds of soldiers into this city in an attempt to prevent further outbreaks of violence.

Senior Israeli civilian and military officials, including Prime Minister Menachem Begin, condemned the attack and vowed to make every effort to apprehend the gunmen. By tonight, there were no reported arrests in connection with the attack.

Today's violence in Hebron followed an incident on July 7, in which a 19-year-old Jewish seminary student from Qiryat Arba was stabbed to death by several Arabs as he waited for a bus outside the city's central market. In retaliation, Jewish settlers set fire to the Arab market, and the next day Israeli authorities dismissed Hebron's acting mayor and its elected city council.

Hebron has an Arab population of about 70,000 and is the most conservative of the West Bank cities. Considered a holy city by both Arabs and Jews, it is a center of increasing tension between the two groups that is certain to be exacerbated by today's incident.

Maj. Gen. Ori Orr, the Army's central commander, said in a radio interview that the investigation into today's shooting will extend to both Arabs and Jews. He said authorities had no description of the gunmen, adding, "We don't know who we are looking for."

Orr also said he saw no immediate connection between the attack on the university and the stabbing death two weeks ago of Aharon Gross, the Jewish seminary student.

Most Palestinians appeared convinced, however, that today's attack was the work of extremist Jewish settlers.

Today's attack occurred at about noon while the university's students were attending classes in the school's single, four-story stone building or standing in a courtyard in front of the building.

Accounts of the shooting varied. Israeli Army officials initially said four masked gunmen were involved, but later revised this to two or three gunmen. According to other accounts, only two armed men entered the courtyard while a third, and possibly a fourth, waited in a car on a nearby street.

Military officials said the shooting lasted two or three minutes and that during the attack one hand grenade was thrown inside the building through its main door. The gunmen then fled to the waiting car and escaped, officials said.

It was not clear tonight how many of the 33 injured were wounded by gunfire or the grenade blast. Several students were injured when they jumped from third- and fourth-story windows in an apparent attempt to escape what they thought was an attack inside the building.

Military authorities said the gunmen apparently were armed with Soviet-made Kalashnikov automatic rifles. According to some accounts, they covered their faces with red and black kaffiyehs, the traditional Arab headdress.

Several victims who were interviewed tonight said they did not see the gunmen. At Beit Jalah Hospital near Bethlehem, where she was being treated, Hanna Jimma, 16, who had been visiting a relative at the university, said all she recalled was seeing "sparks" from inside the building and then feeling pain in her leg, where she was shot.

Israeli authorities identified the three dead as Saad Edin Hassan Sabri, Jemeyal Saad Nazal and Samih Fathi Daoud, and said all were 30 years old. Palestinians said the victims ranged in age from 24 to 28 and identified Sabri and Nazal as West Bank schoolteachers who were taking summer courses at the university.

Most of the injured were in their late teens or early twenties, according to an Army list of the victims.

There were few details available tonight about the shooting death in Nablus, which occurred about four hours after the Hebron attack. Military sources said that one Israeli soldier was injured by stone-throwing Arabs and that there were "four cases of shooting back" by soldiers during the disturbances. One of these cases apparently resulted in the death of the Arab woman, said to be about 20, and the wounding of the other.

Shortly after the shooting at the university, Hebron was sealed off by Army roadblocks while numerous military vehicles brought additional soldiers into the city. Early tonight, reporters were allowed into the city.

All shops were closed and the streets almost entirely deserted except for Army patrols and checkpoints.

The university building, located on a small hill at the northern end of the city, was quiet and dark tonight. But the evidence of the midday violence could be seen in bloodstains on the walkway the gunmen charged up and shattered windows through which they fired into the building.

Senior Israeli officers rushed to Hebron after the shooting, and later today Lt. Gen. Moshe Levy, the Army chief of staff, reported on it personally to Begin. Israeli radio quoted Begin as saying the attack was a "despicable act."

In May 1980, Hebron was the scene of another grisly attack when six Jews were shot to death in an ambush. A month later, in apparent retaliation for this attack, two Arab mayors of West Bank cities were maimed by bombs planted in their cars.