President-elect Bashir Gemayel was killed today when a bomb blew up a local office of his Phalangist Party in East Beirut moments after he had arrived there.

No one claimed responsibility for the explosion, in which at least eight other persons died and 50 were wounded. Gemayel, 34, was elected president three weeks ago and was to take office Sept. 23.

Observers here feared his death would lead to renewed fighting in Beirut between members of Gemayel's Lebanese Forces militia and Moslem and rival Christian groups.

Late tonight, after word of his death had spread, the Lebanese Army closed the Green Line dividing the predominantly Moslem western and Christian eastern sectors of the city to all traffic.

The first official word came from Prime Minister Shafik Wazzan, who issued a statement confirming the news and calling the assassination "a link in a chain of criminal conspiracies against Lebanon at a time when it started to restore its strength."

In a statement issued nearly 12 hours after Gemayal's death, President Elias Sarkis praised the Christian leader as "a martyr to the cause of unifying Lebanon." Sarkis declared a 7-day period of national mourning and appealed to the nation for unity during the crisis, The Associated Press reported.

Before dawn Wednesday, Israeli jets roared low over East Beirut on reconnaissance missions, but otherwise the city was quiet.

Before the announcements, there had been confusion about Gemayel's fate beginning about an hour after the 4 p.m. blast, when the president-elect was reportedly seen alive.

At the time of the explosion, party sources said, more than 100 people were in the building, where Gemayel was attending a regular meeting with local party officials. Although panic spread quickly through the Christian sector of Beirut, initial reports from eyewitnesses said that Gemayel was found alive in the rubble and walked to an ambulance.

"He lives, he lives, thank God," shouted the crowd that had gathered to watch a crane pulling up concrete blocks. Tense Lebanese Forces militiamen who had cordoned off the streets began firing into the air in celebration.

After early reports that Gemayel had sustained only minor injuries, there was no official comment on his condition. Then word began to spread throughout the city of his possible death. Late tonight, it was confirmed by Phalangist Party and government sources.

Phalangist sources said that 20 people were killed, including senior party officials, and 60 injured in the explosion.

The Phalangist Party radio, "The Voice of Lebanon," began playing funeral music and telling its listeners to be calm pending an important announcement. The radio urged Phalange followers not to wear their militia uniforms nor carry their guns.

Party sources explained the initial confusion by saying that the man seen coming out of the rubble surrounded by aides and bundled into an ambulance was wearing clothes similar to Gemayel's.

But party officials who followed the ambulance to the Hotel Dieu Hospital in the Ashrafiyeh section of East Beirut discovered that the man was not Gemayel.

According to reliable Lebanese sources, Gemayel's body was discovered under the rubble at 10:30 p.m., 6 1/2 hours after the explosion. The body was taken to the hospital, where it was identified by his father, Pierre, his wife, Solange, and his elder brother, Amin. Gemayel's body then was taken to his home town of Bikfraya, 15 miles from the capital, to lie in state. Sarkis said a state funeral will be held there Wednesday.

Because Gemayel had not yet taken office, Sarkis will continue as president until parliament is convened to hold a new election. Under a 1943 agreement among this country's rival religious and ethnic groups, the presidency is held by a Maronite Christian and the prime minister's office by a Sunni Moslem. At the time of his election, Gemayel had no serious rivals and analysts here doubt a strong new candidate will emerge.

A Lebanese friend of Gemayel's, newspaper editor Rafiq Shjalaba, called his death "disastrous for Lebanon." He quoted Phalangist explosive experts as saying the blast that demolished the Ashrafiyeh headquarters came from at least 440 pounds of dynamite. This, he said, indicated it had been done by professionals with access to huge quantities of explosives, expert timing devices and access to the heavily guarded building.

"One has to ask a thousand questions about this," the night editor of the respected An Nahar newspaper said, fighting back tears. "Why? Who? For whom? Or for what purpose?"

As word spread of the death of the president-elect, a mood of deep apprehension grew in the Moslem sector of the city, which expected, instinctively, to be somehow blamed.

One worried Palestinian academic in West Beirut said, "This plunges one half of the country into sheer despair, and the other into pure terror."

In Tel Aviv, several Israeli officials expressed sorrow and condemned the assassination, United Press International reported.

The speaker of Israel's parliament, Menachem Savidor, visiting in Puerto Rico, told the Associated Press that Gemayel's death was a "tragic event" that could "change the whole situation."

Today's bombing was at least the third attempt on Gemayel's life in his brief political career. In 1979 a car bomb targeted for him was discovered and defused. A year later, on Feb. 23, 1980, a car bomb was detonated as his limousine passed it in the streets of Ashrafiyeh. Gemayel was not in the car that day, but his 18-month-old daughter, Maya, was killed along with three bodyguards.

At the time, those assassination attempts were blamed by Gemayel's aides on supporters of former president Suleiman Franjieh, like Gemayel a Maronite Christian. The bombs were reported to be retaliations for the killing by Gemayel's militiamen of Franjieh's son, Tony, his wife and their 2-year-old daughter, along with 30 of their bodyguards, in 1978.

As the Christians' military commander since 1976, Gemayel based his power on the militia, eventually usurping the leadership of the Phalangist Party founded by his 77-year-old father. The younger Gemayel has been opposed by fellow Christians, such as Franjieh, for the way he dealt with rivals in the Christian enclaves of Lebanon. Moslems feared him for the savageness with which he directed his militias against them during the 1975-76 civil war. The Moslem leaders additionally considered Gemayel a tool of the Israelis, who have long supported and armed his militia.

Gemayel, however, outmaneuvered his opponents last month and succeeded in getting the votes he needed to be elected president by Lebanon's parliament.

Since then, he tried repeatedly to break down Moslem opposition by preaching reconciliation and stating at every chance that he wanted to be "the president of all Lebanon" not just of the Christians, as his detractors maintain.

Moslem leaders allied to Franjieh in the still Syrian-dominated north of Lebanon refused to have anything to do with Gemayel, stating that they did not recognize the legality of his election. West Beirut's more influential Moslem leaders, gathered around former prime minister Saeb Salam, had increasingly moved toward accepting Gemayel's presidency.

Moslems who considered him pro-Israel were further concerned when Gemayel received a letter of congratulations on his election from Israeli Prime Minister Menachem Begin. But Gemayel denied any collusion with Israel and insisted, "The Israelis are fighting for their own reasons, not my pretty blue eyes."

Gemayel, since his election, had said that all militias, including his own, should be disbanded once the Lebanese Army was capable of assuming security around the country. The Army so far has failed to take hold in Christian East Beirut, where the Lebanese Forces remain the principal authority.

Prime Minister Wazzan, a Moslem announced this week that the National Police, backed by the Army, would begin to deploy in East Beirut, as they have in the western part of the city, on Wednesday. Tonight, however, Wazzan said that the scheduled opening of the Fuad Chehab bridge crossing point would be postponed.

Bashir Gemayel, the youngest of six children, joined the Phalangist Party at the age of 11 during the first Christian-Moslem civil war here. Two years later he began military training in the militia, then called the Kataeb, and by the age of 22 he was in command of a unit.

He studied law and political science at a Jesuit college here and participated in student groups opposed to the leftist supporters of Palestinian nationalism.