Four French military personnel were killed today and U.S. Marines, again under attack, returned fire for more than two hours as armed militiamen and the Lebanese Army battled across Beirut for the second straight day.

Today's fierce clashes, among the worst since the 1975-76 civil war, underscored growing fears here of a renewal of all-out conflict.

Throughout the afternoon and evening, the sounds of mortars and gunfire crashed and crackled on the streets of predominantly Moslem west Beirut as Moslem militiamen moved to reestablish themselves in positions they held during the last civil war.

Tonight long-range artillery fire rocked west Beirut after Lebanese state radio reported a Cabinet decision to send Army units into the sector to "restore calm."

There were efforts by the teetering government of Lebanese President Amin Gemayel to restore the relative quiet that had existed here in recent months, but they appeared futile in the face of determined efforts to defeat his Army and overthrow his government.

The four French deaths today occurred in two separate attacks, the Defense Ministry announced in Paris. Two French soldiers and a paramilitary policeman died in a shelling attack at the French Embassy in which several other persons were injured. A third French soldier was killed and two others wounded in an attack at the Galerie Semaan crossing point along the so-called Green Line that demarcated Moslem and Christian areas until Israeli troops entered the city last year.

British and Italian contingents in the four-nation peace-keeping force here also came under fire, and an Italian soldier was reported to have been injured. The British commander, Lt. Col. David Roberts, told Reuter he thought the shelling near British positions on the southern end of the city was aimed at Christian positions, not at the British peace-keeping troops.

The chaotic situation here thrust the members of the 5,400-man peace-keeping force into a quandary--how to respond. U.S. Marines, who fired a salvo of artillery into Druze-controlled foothills surrounding the capital yesterday after two marines were killed in heavy shelling, responded to today's attack initially by sending up innocuous illumination rounds.

Earlier today U.S. officials had attempted to deter attackers by bringing the aircraft carrier Dwight D. Eisenhower into Lebanese waters close to shore in a show of force. Marine Cobra helicopters also orbited above the coastline.

These actions did not stop militiamen, unidentified by Marines early this evening, from attacking this afternoon with small-arms fire and following up with rockets and mortars that landed close to virtually every Marine position around Beirut International Airport.

In Washington, the Pentagon said Marine positions around the airport came under small-arms fire around 11 a.m. EDT and the Marines went to their highest alert stage, United Press International reported; firing ceased about 1:10 p.m. Heavy mortars were aimed at Lebanese Army positions north of the airport and mortars and rocket-powered grenades were aimed at the Marines' B Company near Lebanon University, the news agency added. The Marines responded with small-arms fire and machine-guns but no mortars, officials said.

Late this evening, heavy shells, believed to be 130mm artillery coming from Druze positions, rained on west Beirut. Rounds seemed to be falling in an arc stretching from the Holiday Inn to Marine positions around the airport. Marines said they silenced the barrages by sending up illumination rounds to tell the gunners that they knew where the firing was coming from.

At the same time as the earlier attacks around Marine positions, Moslem gunmen attacked Lebanese Army garrisons in the capital and attempted to take control of two strategic high-rise buildings held by the Army that were the focus of battles during the civil war.

Lebanese soldiers reportedly moved to protect U.S. Embassy personnel and Marine trainers living in the Cadmos Hotel near the embassy. Embassy personnel have been housed in hotels and other buildings since the embassy building was blown up in a bomb attack in April.

State and private radio stations said Lebanese soldiers landed by boat and helicopter at the beachside Cadmos Hotel and attacked Druze militia gunners threatening the site from the nearby Holiday Inn, The Associated Press reported. The broadcasts reported fierce fighting.

The office of Prime Minister Shafiq Wazzan came under heavy fire earlier today. Wazzan reportedly was not in the building at the time.

The Italian Embassy also came under attack but escaped potentially heavy damage when a rocket that landed nearby failed to explode.

In Jerusalem, President Reagan's special Middle East envoy, Robert C. McFarlane, was able to secure a commitment from Israeli officials to delay for another three or four days their partial withdrawal fom the Chouf Mountains south of the capital.

That appeared here to be something of a reprieve for Lebanese who fear the consequences of a linkup of two raging conflicts here: the principally Shiite Moslem battle against the Army in the capital and the battle of the Druze community against the Army and Christian militiamen in the mountains. Fighting in the mountains tapered off in recent days.

There were indications in the streets of Beirut and in a statement by the Druze Progressive Socialist Party that a military alliance had already been struck.

A party statement issued in Damascus today declared "all-out support" for the Shiites and pledged its help to prevent the " Christian Phalangist authorities" from forcing the Shiites "to knuckle under."

Shiite leader Nabih Berri appeared anxious to stop the fighting and held a press conference tonight in which he ordered his militiamen off the streets. But Berri did not appear to be in full control of those fighting under his organization's bannner, and the heavy shelling tonight began after his announcement.

Moslem political leaders met late today and decided that despite their dissatisfaction with Gemayel and his fellow Christians, they thought it important that the Army extend its control over the capital. Berri's announcement followed the meeting.

As Shiite snipers and militiamen, many in masks, fired weapons and took control of streets, an Associated Press reporter heard him shouting to an aide today:

"I don't want any more shooting, no violation of the cease-fire with the Army . I want the cease-fire called yesterday by President Amin Gemayel to hold. Why are they shooting?"

Fighting in the capital began Sunday, triggered by what appeared initially to be a minor incident.

Young Shiite Moslem militamen in a village in the south of the capital near the airport were pasting on walls posters of Shiite spiritual leader Imam Musa Sadr, who disappeared five years ago on a trip to Libya. A Renault sped by and fired on the young men, killing one of them and wounding another. A Lebanese Army armored patrol came to investigate but quickly became the focus of the anger of the Shiites. Trouble mushroomed to include attacks on nearby Lebanese Army positions, including one manned by U.S. Marines. Marines fought a 90-minute battle against attacks Sunday. Yesterday they were barraged for more than five hours by rockets and mortars, including one round that struck a bunker and killed two marines.

Both CBS News and Reuter, the British news agency, abandoned their offices in a building near the Green Line today. Moslem militiamen from the Progressive Socialist Party, the Shiite group Amal (Arabic for "hope") and the pro-Nasserite Marabitoun Party used it as a position from which to fire on Lebanese soldiers guarding nearby buildings and the prime minister's offices.

Five young men rushed into the office building this afternoon and fired at the soldiers, shouting to them, "Soldier, give up your arms. You will be saved." Small children rushed in and out to resupply the militamen with ammunition.

After the shooting stopped, Washington Post special correspondent Nora Boustany, one of the journalists who had been trapped in the building, confronted the youthful gunmen. "Who are you?" she asked.

"I'm Amal," said one proudly.

"We're PSP" said another.

"I'm Mourabitoun," a third said.

Why were they firing at the soldiers, she asked.

"This is destiny," said one. "We are fighting for our children and the children of our children."

Foreign observers have been surprised to find familiar faces among the fighters. The affable busboy suddenly comes out of the closet as a Shiite militiaman. He says he has had his gun hidden away since last summer. The familiar guard hops in a car in the afternoon to go off and join his comrades in the Mourabitoun.

There is in their adventures a demand for recognition--and deadly force.

Militiamen battled the Army this evening for control of the high-rise Holiday Inn and the Murr building, a 40-story skyscraper, before the clashes tapered off. Both buildings are near the Green Line. Both were occupied at the outbreak of the 1975-76 civil war and were converted by various militias and later the Syrians into strategic positions.

For the ordinary citizen here, inured to continuing conflict, there is the effort to cope. Militiamen were inactive this morning and shops opened for a few hours. Until around noon the streets were crowded as people put in supplies of bread, fruit, water and toilet paper. There were good-sized crowds at sidewalk cafes, sipping Turkish coffee and exchanging the latest news.

"Why shouldn't they be here?" said a waiter. "No place is safe here."