Widespread shelling pounded both Christian and Moslem quarters of Beirut and its suburbs for more than four hours today, killing at least six persons and wounding 34 others in the most extensive artillery barrage since the Israeli siege last summer.

Some of the shelling appeared to come from the Israeli-occupied mountains overlooking Beirut, where Christian Phalangist and Moslem Druze militiamen have engaged in artillery duels for months. Lebanese state television reported that Lebanese Army helicopters determined that other rounds were fired from Syrian-held territory.

It was impossible to determine who was responsible for the shelling. The Christian and Druze militias each accused the other.

The helicopter of Col. James Mead, commander of the U.S. Marine contingent of the multinational peace-keeping force here, was hit by three .50-caliber rounds when he flew into the fighting in the Israeli-held mountains to determine where the artillery was being fired. None of the marines in the helicopter was injured.

Mead said later he took the helicopter up on a reconnaissance mission, the first time that marines have flown into a firefight here, because he was concerned after some rounds fell close to the French contingent's command post.

"It was a very confusing situation, and one has to get information very rapidly," Mead later told reporters. "So the way to get it is to get into your command helicopter and go get it."

Lebanese President Amin Gemayel directed his Army commander to telephone the Syrian Army commander in Damascus to ask that Syrian forces in Lebanon prevent their supporters from shelling Beirut from Syrian-occupied territory, according to local news reports. The Syrian commander was quoted in the reports as saying he was not aware that any of Syria's allies had shelled Beirut.

There was no report of Gemayel making a similar entreaty to the Israelis, who frequently have acted as mediators to quell fights between Christian and Moslem Druze militiamen in the mountains. Lebanese have frequently alleged, and Israeli spokesmen have denied, that the Israelis turn on and off the battles there at will.

According to local radio reports, Gemayel also ordered Lebanon's fledgling Air Force and Army to "attack and silence" any positions shelling Beirut.

The artillery barrages, which began shortly before noon and continued until later in the afternoon, are part of a trend of escalating violence in the capital in recent days. This week there have been nightly barrages, although previously they had not caused casualties but only damaged stores and shops.

The barrages today were far more extensive, cutting an arc that ranged from the area around the presidential palace in an eastern suburb of Beirut through southern areas of both Christian East Beirut and predominantly Moslem West Beirut, and to coastal areas north of the capital.

One shell landed about a mile away from the presidential palace, rattling windows there, according to a visitor.

As is often the case here, victims appeared largely to be non-combatants. A motorist driving down a busy West Beirut boulevard near the French command post at midday happened to be there when nine shells landed in the middle of the thoroughfare. He was killed instantly. Five others in his car were injured.

There were reports that a shell smashed through the wall of a sixth-floor apartment in the posh Ashrafiyeh section of East Beirut, killing a man who was taking a shower.

One shell that landed southeast of Beirut killed an Israeli sergeant and wounded nine other Israeli soldiers, Israeli military officials said.

There was deep concern about the violence in the capital but hardly panic in a country that has experienced eight years of carnage.

This reporter learned about today's shelling from a hotel waiter. He lived in an area that had been struck and had been getting play-by-play telephone reports from his mother. He came out of the kitchen and served lunch while telling what she had said.

[The Lebanese Forces Christian militia blamed the Moslem Druze militia for bombarding Beirut and said that Syria instigated the attacks to sabotage Secretary of State George P. Shultz's attempt to negotiate an agreement for withdrawal of foreign forces from Lebanon, The Associated Press reported.]

[The Druze militia blamed the Lebanese Forces, saying that the Christian militia "began shooting at people in the streets or working in their shops and fields" in the mountains east of Beirut.]