As the sun sank on the Mediterranean today, U.S. marines read from the 23rd Psalm and sang "Amazing Grace" in commemoration of their first combat deaths in Lebanon.

Two M60 tanks were a backdrop for the somber battlefield service only a few yards from the tent where 2nd Lt. Donald G. Losey Jr., 28, of Winston-Salem, N.C., and Staff Sgt. Alexander M. Ortega, 25, of Rochester, N.Y., eulogized as dedicated family men and gung-ho marines, died in an artillery barrage Monday morning.

The long barrels of the Marines' tank-mounted guns pointed at the nearby mountains from where the shells had come. Another tank aimed at the heavily armed Shiite Moslem slums a half mile away.

The battalion commander urged the grim-faced men of Alpha Company not to let their heads hang low, but his own voice was tinged with emotion.

"Our country, our way of life can only survive as long as we have strong young men who are willing to pay the ultimate price if it is called for," Lt. Col. Larry Gerlach told them. "They died in a very difficult mission," he said. "They died in a mission of peace-keeping. It calls for dedication, it calls for discipline and it calls for restraint."

The frustration of that restraint could be seen in the succession of names the marines have given their beer and snack bar.

At first they called it the "Can't Shoot Back Saloon." Then last month when the Marines fired illumination rounds at artillery positions in the mountains they changed it to the "They Can Shoot Back Saloon." After the death of Losey and Ortega, the Marines fired a salvo at the mountain attackers, possibly killing some. The name was changed again to the "They Did Shoot Back Saloon."

Beirut was calm today after a week of shelling and gun battles.

In the Shiite Moslem slum, Burj al Barajinah, north of where the Marines held their memorial service, piles of garbage burned. Cars charred in Monday's battle still stood in front of shell-pocked dwellings as tense, angry, tough-looking young men roamed the dirt streets with weapons slung over their shoulders.

From that area, a machine-gunner on Monday fired at a Marine Cobra helicopter that was spotting the artillery barrages from the mountains. Marine gunners fired a rocket back.

"We were very conservative with the marines," said Mohammad Haidar, a militiaman, as he led visitors through the narrow streets today. "All of their locations are within our range of fire."

The Lebanese Army's tank advance into west Beirut on Wednesday largely cleared the streets of the predominantly Moslem sector of the militiamen who had taken over earlier, but sniper fire crackled intermittently in isolated pockets today.

A cordon of Lebanese soldiers surrounds Burj al Barajinah in the southern outskirts but inside, young men in T-shirts and blue jeans with Kalashnikov assault rifles and grenade launchers are clearly still in control.

"We have always said we are not the alternative to the government," Haidar said as he raged about bad schools, rutted roads and the rubble. "But we can't find anybody who listens to us. That's why we are always fighting the government."

Most of the enlisted ranks of the Lebanese Army are, like the militiamen, Shiite Moslems, and many of them come from Burj al Barajinah.

"The fighting was really very hard," said Sam Seblani, a militiaman, of Monday's battles. "You are shooting and you don't know who you are killing. Maybe your uncle. Maybe your brother."

There is for the moment here an accommodation in the fratricidal division. The young men from Burj al Barajinah in the Lebanese Army are permitted by the militiamen to return, unarmed, to look in on their families. A few did so this afternoon, enduring only taunts.

To the south, the U.S. chaplain, Lt. Cmdr. George Pucciarelli, in white vestments and black combat boots, eulogized Losey and Ortega for having died "to give time to our Lebanese Army to get themselves in shape so that they can fight their own battle and bring peace to Lebanon."

The men of Alpha Company and the others in the 1,200-man Marine contingent have built sturdier bunkers, connecting them by deeper trenches.

"We've improved our positions and we're continuing to improve," said Maj. Robert Jordan. "What we thought was going to be a short stay is obviously going to be a longer stay."