JERUSALEM (AP) _ Israeli troops sealed the borders of the occupied territories today in an effort to curb a wave of bloody revenge attacks by Arabs and Jews.

An order from Defense Minister Moshe Arens banned the nearly 1.7 million Palestinians in the West Bank and Gaza Strip from entering Israel after attacks on Tuesday left two Arabs dead and seven people wounded.

In Jerusalem, tensions over the killings of Palestinians on the Temple Mount on Oct. 8 increased with the death today of a 20th Arab victim.

Police sources and family members said Salim Ahmad Khaldi, 18, was apparently shot by an Israeli civilian on a street near the holy site during the melee. Most of the other victims were killed when police charged the shrine, which is holy to both Arabs and Jews.

Hospital officials said another Arab also died today of beating wounds suffered at the hands of Israelis after he stabbed two women soldiers on Tuesday in northern Israel.

A general strike was called in Arab east Jerusalem, and uprising activists ordered merchants in the main Arab shopping streets and the narrow alleys of the Old City to close.

In an interview on army radio, Arens denied that confining Palestinians to the territories amounted to returning to the 1967 border before Israel captured the land. ''We have to take the correct steps to ensure our control over this country and the safety of the citizens,'' Arens said.

He said he hoped Palestinians would realize ''that persisting in these violent attacks will only increase the tragedy of the Palestinian people.''

Defense Ministry spokesman Dan Naveh said the order would ''last for several days'' and should not seriously affect the troubled Israeli economy.

About 110,000 Palestinians work in Israel, and Israel radio said Jerusalem employment agencies got 20 times the usual number of calls for construction workers, cleaners and other jobs filled by Arabs from the territories.

At the Erez crossing into the Gaza Strip, thousands of Palestinians arrived today in private cars, taxis and buses. Many carried suitcases or makeshift bundles as they were loaded into buses and trucks to go home.

Israel radio said at least 600 Israelis in Tel Aviv called police to report the whereabouts of Arab laborers who had stayed behind despite the order.

Fear of Palestinian attacks has gripped many Israelis, and the daily Maariv published a guide today on how to defend against a knife-wielding attacker. Interior Ministry officials also reported brisk trade at Israeli gun shops.

Just hours before the closure order on Tuesday, Israeli civilians fired on an Arab-owned car near the southern Negev town of Mivtahim, killing Maher al- Shaher, 30, a Gaza laborer, and wounding his three cousins, one seriously.

The army said the incident was being investigated by police. Responsibility for the attack was claimed by a previously unknown underground group, ''Eye for an Eye,'' in phone calls to Israel Television and radio.

The laborers, who were returning from work in Israel, said they saw a civilian firing an Israeli-made Uzi submachine gun at them from a Jeep, Israel's news agency Itim said.

Earlier Tuesday, a Palestinian knifed two unarmed women soldiers and another Arab bludgeoned two Israelis with a hammer, police said.

The knifing occured in Kiryat Tivon in northern Israel, when Omar Shawaneh, 39, of the West Bank village of Silat el-Harithiya shouted ''Allahu Akbar'' (God is great), then stabbed two women soldiers who were hitchhiking.

Police said Shawaneh was captured by a group of soldiers and civilians and witnesses said he was severely beaten. He died today of head injuries at Rambam Hospital in Haifa, officials said.

One of the soldiers, Naama Yekutiel, a youth instructor, was in serious condition today withy a chest wound that punctured a lung.

Also Tuesday, in the southern coastal city of Ashkelon, an Arab machine shop worker wielding an 11-pound hammer battered his Israeli employer and a neighbor, police said.

Both were hospitalized and the 23-year-old Palestinian, who claimed to be avenging a friend killed in Gaza, was arrested, police said.