All 86 passengers and crew aboard a hijacked Lufhansa airliner were freed unharmed early this morning after a heavily armed squad of West Germa commandos shot its way aboard the plane in a daring night attack in Mogadishu, Somalia.

The assault came just 90 minutes before a new deadline in which the hijackers had once again threatened to blow up the plane and its passengers unless their demands for the release of 13 jailed terrorists from West German and Turkish jails were met.

Initial reports reaching this relieved West German capital were that all four hijackers were killed in the raid and that only one 60 special West German antiterrorist commandos was wounded.

Initial broadcast reports here said the commandos blew open the doors of the plane and that the entire action was over in about two minutes.

The raid brings to an end a five - day, six-country odyssey of the Lufthansa Boeing 737 jetliner and a terrifying ordeal for the passengers and crew, an ordeal in which the plane's pilot was murdered yesterday aboard the craft by the terrorists in front of all the passengers.

First sketchy reports of the successful assault and rescue flashed over West German radio and television shortly before 1 a.m. here and shortly after Bonn authorities had reason to fear the secret attack might be thwarted.

Earlier in the evening a news agency report from Israel, apparently based on monitored radio conversations between a special West German Boeing 707 jet carrying the commandos and the airport control tower, gave away the fact that a plane had landed after dark with its landing lights out at the Somali capital.

West German officials immediately put out a request for all news agencies not to repeat that report and apparently the hijackers aboard the plane never heard it and the surprise was intact.

The elite unit that stormed the jetliner was formed after Palestinian terrorists had massacred Israeli athletes at the 1972 Olympic Games at Munich. This was the first time the group had gone into action specifically on the type of assault for which it was trained.

Despite the earlier death of the plane's 37-Year-old pilot, the successful attack is being viewed as a major blow to the recently rising fortunes of West German terrorists and a vindication of the tough stand taken by the government of Chancellor Helmut Schmidt against both the hijackers and the extreme leftist German terrorists who kidnapped industrialist Hanns-Martin Schleyer on Sept. 5.

It was the kidnaping of Schleyer - whose fate is still unknown - that originally set the demand for release of 11 of West Germany's most notorious terrorists from prison here. When the Bonn government failed to give in after some six weeks, another group of terrorists, including some Arabic speaking members and apparently acting in consort with their West German comrades, hijacked the Lufthansa airliner Thursday afternoon over the Mediterranean on a flight from Mallorca to Frankfurt.

Reports reaching here said that one of the Lufthansa Boeing 737's pilots was accused by the hijackers of trying to escape while the plane was in Aden, South Yemen, Sunday. A quick "trial" was held in the cabin and the pilot was executed on the spot. His body was covered but left to lie in the aisle in the middle of the stifling passenger cabin for some time, according to reports viewed here as reliable.

It was not clear if the pilot was killed while the plane was in Aden or when it was flying to Somalia Monday morning. The only other crew member known to be able to fly the plane was the copilot.

Passengers were forced to step over the body if they wanted to get water or have access to oxygen. Eventually, the reports said, the body was pushed into a closet when the smell and the fear became overwhelming.

When the plane landed at Mogadishu, the capital of Somalia. Monday morning, the wrapped body of the pilot was dumped onto the runway.

Despite this display of power, the hijackers failed to carry out their threat to blow up the plane when the West German government let two deadlines go by without complying with the terrorists' demands.

Somalia, on the east coast of Africa, was the fifth country the hijackers have forced the plane to during its odyssey through the Middle East. The plane was seized Thursday on a flight from the spanish island Mallorca to Frankfurt. It stopped briefly for refueling in Rome and on Cyprus before flying to Dubai, on the Persian Gulf, where it sat for two days f before leaving Sunday afternoon.

On Sunday night, the twin-engine jet made a rough landing on a dirt strip adjacent to the main runway in Aden, where afficials had refused permission to land.

It was at about the time the plane left Aden for Somalia that the passengers, already terrified, were exposed to the grisly "trial" and execution of one of the plane's pilots, according to sources close to the situation.

These reports, said to have been transmitted first - hand through an undisclosed channel, indicated that there was rising fear among the exhausted passengers that the terrorists are fanatical enough to die in an explosion of their own making if their demands are not met. Although the West German government has not confirmed the dead pilot's Identity, the Somali news agency has reported that he was the plane's captain, Juergen Schumann, 37. West German government spokesman Klaus Boelling reported that a notebook in the dead pilot's pocket had Schumann's wife's name in it.

Ironically, well-intentioned praise for the dead pilot by the defense minister of the United Arab Emirates could have had something to do with his death. The defense minister, who talked by radio with the pilot when the plane was on the ground in Dubai, told reporters later that the pilot had cleverly revea ed in the conversation that there were four hijackers aboard and what kind of weapons and explosives they appeared to have.

The lingering life - and - death drama has confronted the chancellor Helmut Schmidt's government with one of the worst crises since the post - war republic was founded.

Monday, relatives of several passengers went to Schmidt's office to appeal to him to give in to the demands and release the jailed terrorists.

The Schmidt government has kept its moves secret throughout the crisis, which actually goes back 43 days to Sept. 5, when extreme leftist German terrorists kidnapped Schleyer and lodged the original demand that their 11 comades - including some of this country's most notorious urban guerrillas - be freed.

The kidnapers of Schleyer are members of the "Red Army Faction," followers of the Baader-Meibhof gang that spread terror through West German cities in the late 1960s and early 1970s. Its leader, Andreas Beader, is among the jailed terrorists whom the kidnapers and hijackers wanted freed and flown out of the country.

The hijack group called itself the "Struggle Against World Imperialism." While it was clearly working in unison with Schleyer's kidnapers, it also seemed to have terrorists of other nationalities in its ranks aboard the plane.

This suggests the existence of an international ring of terrorists that is able to coordinate acts of violence with considerable skill. It also helps to explain why Bonn, despite the huge human and political stakes, is relucant to set free 11 more persons who could feed the growth of the terrorism that has shaken this country badly.