MASHGARA, Lebanon (AP) _ The pro-Iranian Hezbollah militia declared Thursday it will avenge an Israeli attack on one of its strongholds in which the Israelis say about 40 guerrillas were killed.

''We shall retaliate. The battle with Israel is still in its initial stage,'' said Subhi Tofeili, a clergyman who is a leader of Hezbollah, an extremist Shiite Moslem group whose name means Party of God.

''The torch of resistance will continue to burn despite Israel's attacks,'' Tofeili told a news conference at a mosque in this Bekaa Valley town four miles north of Maydoun, the stronghold assaulted by the Israeli army the day before.

Mashgara, the Syrian army's most forward garrison town in the Bekaa, came under Israeli artillery fire Wednesday, but no casualties were reported. Syria has about 50 soldiers in Mashgara and about 16,000 in the Bekaa.

An Israeli announcement said the battle, and the army's two-day thrust into south Lebanon in search of guerrillas, ended Wednesday night with three Israeli soldiers dead and 17 wounded. It said about 40 Hezbollah fighters were killed at Maydoun.

Tofeili conceded 10 guerrillas killed. He said eight were wounded and one was taken prisoner ''in the heroic battle.''

He said the Israelis demolished Maydoun's 60 houses after the fighting.

A Hezbollah statement claimed more than 30 Israeli soldiers were killed or wounded in the 11-hour battle for Maydoun.

Hezbollah sources said the Israelis remained in the village Thursday. Reporters who tried to enter Maydoun on foot at about noon Thursday came under fire and returned to Mashgara.

''I think the Israelis will eventually withdraw from Maydoun, but I hope they stay there close to us where they are a precious and easy prey,'' Tofeili said.

The Hezbollah leader, wearing a white turban and black robe, said his organization has ''promised Imam Khomeini that we will keep up the struggle against the Zionist entity (Israel).'' He was flanked by a half dozen other Hezbollah clergymen wearing green battle fatigues under their robes.

Hezbollah swears allegiance to Ayatollah Ruhollah Khomeini, Iran's revolutionary patriarch.

Israel began the operation Monday night, a week after two raids into Israel by Palestinian guerrillas in which five guerrillas and two Israeli soldiers were killed.

Although its main target was Palestinian guerrillas, the operation developed into a confrontation with Hezbollah at Maydoun.

Maydoun is north of the ''security zone'' Israel created just inside Lebanon after it withdrew in June 1985 from a three-year occupation of south Lebanon.

The zone, which ranges in depth from 6 to 10 miles, serves as a buffer against cross-border into northern Israel. It is guarded by Israeli soldiers and a surrogate militia, predominantly Christian, called the South Lebanon Army.