Two U.S. marines were killed and 14 wounded today amid heavy shelling and fighting here that brought Lebanon to the brink of full-scale civil war.

After their positions were barraged with rockets and mortars for more than five hours this morning, marines responded with a salvo from their 155-mm artillery on Druze positions in the foothills of the mountains overlooking the capital. A Marine Cobra gunship fired a rocket on a machine-gun position in a Moslem Shiite area after it came under attack.

In house-to-house urban guerrilla warfare in the shell-pocked slums south of the capital around Beirut International Airport, Moslem gunmen battled five brigades of the Lebanese Army. They also attacked Army soldiers at several other positions in west Beirut. The U.S. marines took no part in those operations.

The National News Agency reported that 15 Lebanese soldiers were killed in the fighting and 76 were wounded, United Press International reported. Beirut radio said 10 civilians died and 13 were wounded, although other sources said that toll could go much higher.

Several Lebanese soldiers were kidnaped during the fighting and their armored vehicles captured. An Italian sergeant in the four-nation multinational peace-keeping force reportedly was slightly wounded.

The dead marines were identified by the Pentagon as 2nd Lt. Donald George Losey, 28, of Winston-Salem, N.C., and Staff Sgt. Alexander M. Ortega, 25, of Rochester, N.Y.

The two marines killed today were the first U.S. combat dead in the 11 months since the marines joined the 5,400-man peace-keeping force here.

Today's fierce fighting came after weekend reports of some progress in U.S.-brokered negotiations for a political agreement between the Lebanese government of Christian President Amin Gemayel and the Druze community headed by Walid Jumblatt. President Reagan was reported late last month to be willing to consider expanding the role of the peace-keeping force if agreement is reached between Gemayel and the Druze.

Gemayel called a cease-fire at midday, halting the advance of the Army into the slums where there was the fiercest fighting, after being urged to do so by Moslem religious leaders. The heavy shelling stopped but Moslem militiamen, their faces often hidden by black scarves, still roamed the streets through much of the predominantly Moslem western sector of the capital. Snipers fired at random from rooftops and apartment buildings at several locations in west Beirut.

The gunmen blocked passage between west Beirut and Christian east Beirut for much of the day, setting up positions along the war-battered Green Line, the focus of sectarian battles during Lebanon's 1975-76 civil war. The crackle of gunfire and bomb explosions could be heard sporadically on the streets this evening and there were reports of looting of shops and stores.

The boiling over again of Lebanon's long-festering civil disputes frightened citizens here, forced a severe test for the fledgling Army and Lebanese government and put the marines, here as part of a neutral peace-keeping force, in the midst of civil strife and a tragic dilemma.

"The marines are still reluctant to see themselves positioned between internal factions in Lebanon," said Marine spokesman Robert Jordan, referring to the decision to fire the artillery.

"We do not pick a fight with anyone and as long as our positions are not threatened, we will not fight with anyone."

Marines fought a 90-minute gun battle yesterday, their first in Lebanon, after attackers, whom they believed to be Shiite militiamen, fired automatic weapons and rocket-propelled grenades into an outpost they man jointly with Lebanese Army soldiers. That position along the southern entrance to the Shiite village of Hay es Selloum came under attack again today but the attack was repulsed, Jordan said.

The decision to fire back came shortly before noon after the marines, caught in the crossfire of battles between Moslem militiamen and the Army, had endured barrages of growing intensity since daybreak.

One of those attacks resulted in a direct hit on a bunker on the perimeter of the airport at 9:45 a.m. local time (3:45 a.m. EDT) that killed the two marines and slightly injured three others. Another artillery barrage at 10:15 a.m. (4:15 a.m. EDT) injured other marines. A Marine spokesman in Washington characterized the injuries of the 14 wounded marines as "slight."

Attempting to avoid firing live ammunition, marines first shot illumination rounds over the positions from where they were being rocketed and mortared. When that failed to end the barrages, they fired the 155-mm artillery into the Druze-controlled area.

"We don't know who we were firing at," said Jordan. "All we know is that they were firing at us and we returned fire and silenced them."

Most hospitals in the capital were filled tonight and were sending out appeals for blood donations.

Shells crashed on both the Christian and predominantly Moslem sectors of the capital, hitting neighborhoods and military positions. According to Christian Phalangist radio, at least one shell fell on the grounds of the Lebanese Defense Ministry and another hit the home of the defense minister. Other shells fell near the residence of U.S. Ambassador Robert Dillon and there were reports that two shells fell close to the Lebanese presidential palace.

Other rounds crashed into the Burj al Barajinah Palestinian refugee camp, where the Italian soldier was injured, and there were constant barrages in the Moslem Shiite slums around the airport. Reporters near the scene said they could hear the wails of women trapped there. Moslems accused Christian Phalangists of firing from their positions, which the Phalangists denied. A Lebanese Army spokesman, noting that civilians were often located next to Shiite militia positions, said it was difficult to discern who was firing.

"Both sides were shelling," the Army spokesman said. "We really don't know who was firing."

As a Lebanese Army jet fighter struck and destroyed in the shelling of the airport sent black plumes of smoke billowing overhead this morning and the shells fell around the Marine positions, taxis crammed with women and children sped from the scene. There were mournful songs from nearby mosques, crying out, "Bless the souls of those who died."

Elsewhere in the capital, shops shut down early this afternoon and people rushed home. Aside from the militiamen roaming the streets, the only signs of activity were of motorists lining up at service stations and throngs at little shops seeking to buy bread.

There was a strong feeling of helplessness among residents here.

"Is this the end?" asked a middle-aged Christian housewife who found today's events more troubling than the other battles she had endured in the continuing conflicts here.

"Nobody has control over the situation," a leading Moslem columnist said, "especially the Lebanese leaders." His greatest fear, however, was that the Army would prove unable to put down the violence.

The fighting yesterday and today was triggered yesterday afternoon as young men in the Moslem Shiite organization, Amal (Arabic for "hope"), were putting up posters in preparation for a commemoration Wednesday of the Imam Musa Sadr, spiritual leader of the Moslem Shiite community in Lebanon who disappeared five years ago during a visit to Libya. A car sped by spraying gunfire, killing one of the young men and injuring another.

A 15-man Lebanese Army patrol in two armored personnel carriers rushed to the scene and established a checkpoint. They quickly found themselves surrounded by angry young Shiites and the attacks began. Yesterday's fighting, including the attack on the joint Marine-Lebanese Army position, was mostly confined to the southern suburbs.

But today Moslem gunmen--Shiites, Arab nationalist Moslems and Druze (an offshoot of Islam)--suddenly appeared armed in locations throughout much of west Beirut. Col. Akaf Haidar, chief of Amal's political bureau, said they rallied the support after brigades of Lebanese Army soldiers surrounded Shiite fighters in the suburbs last night. The Army had intended to conduct sweeps through those areas this morning.

Americans training Lebanese Army units said the 10,000 soldiers mobilized to put down the fighting had performed well, had cordoned off an area of 14 square kilometers and penetrated into a two-square-kilometer area when the cease-fire was ordered. The U.S. military officials said some Shiite fighters and political leaders had attempted to rally Shiite soldiers to defect from the Army but that only four had done so.

The Lebanese Army spokesman acknowledged that 12 soldiers were kidnaped by the Moslem gunmen and two Army tanks were captured. Haidar claimed, however, that the militiamen had taken 50 soldiers prisoner and had captured four armored personnel carriers and destroyed seven others. Journalists cruising around west Beirut today encountered two Lebanese Army light tanks that were being driven by Druze militiamen.

Reporters also observed that a number of Lebanese Army positions in the city had been abandoned this evening. Christian Phalangist radio reported later that the Army was returning to strategic positions and seeking to calm the situation. In retaliation for the Army's taking control of Amal's headquarters in the southern suburbs, Shiite militiamen this afternoon seized control of Lebanon state television for four hours.

Gemayel ordered his Cabinet into emergency session this afternoon and it met into the evening.

The new crisis here followed intensive efforts during the weekend by special U.S. Middle East envoy Robert C. McFarlane to bring together Gemayel aides and Jumblatt to make an agreement avoiding bloody clashes when the Lebanese Army is deployed in the mountains overlooking Beirut after Israel's imminent partial withdrawal.