Germany's chief public prosecutor was assassinated today by motorcycle-riding terrorists who pulled alongside the prosecutor's official car and riddled it with machine gun bullets.

The killing of Siegfried Buback, 57, a central figure in the prosecution of alleged leaders of the Baader-Meinhof anarchist gang, took place in the center of the city of Karlsruhe, just a few hundred yards from the country's highest court, as Buback was being driven to work.

The slaying touched off a massive manhunt in West Germany and along the nearby border with France.

The attack, which also killed the driver and critically wounded a bodyguard, is especially troubling to West German security officials because of a series of possibly related recent events.

Just a few days ago, the three remaining suspected leaders of the Baader-Meinhof gang, who are being held and tried in a maximum security prison and courtroom near Stuttgart, called for armed resistance.

As a result of today's killing, authorities are pondering whether the jailed terrorists are still able to issue orders from their prison cells to sympathizers outside.

Today, Stuttgart court authorities approved a prosecutor's office order forbidding the three accused therrorists from talking with each other, seeing their families or lawyers, receiving correspondence, or having radio or television sets.

The three accused terrorists - Andreas Baader, Gundrum Ensslin and Jan-Carl Raspe - issued their latest call for armed resistance in connection with a hunger strike they initiated last week.

The hunger strike was in protest over the disclosure last month that the prison rooms where the three defendants met with their lawyers had been bugged by federal authorities in 1975 and 1976.

State and federal authorities, embarrassed at first by the disclosure that they had bugged defendants in a trial, said they did it because they feared these discussions might be linked to coordinating violent activities aimed at freeing the defendants.

Today's killing also comes just a few days after Swedish police extradited to West Germany two other alleged terrorists - Norbert Kroecher and Manfred Adomeit. They were arrested in Sweden last week along with a dozen other suspects on grounds that they were planning to take hostage a former Swedish Cabinet minister to gain release of terrorists in West German jails.

Sunday, Buback announced the arrest of the two extradited Germans and said they would be prosecuted here.

Buback warned of the danger that was eventually to kill him. He cautioned Sunday against "a small but determined terrorist gang that is always able to attack and has no respect for life."

Buback has been West Germany's chief federal prosecutor for the past three years and in that position he played the principal role in the investigation and placing of charges of bank robbery and murder against the accused, among other things, of bombings in 1972 of U.S. Army facilities here in which four Gls were killed and 14 others were wounded.

The Stutgart trial has been dragging on for almost two years and was thought to be nearing its end when the bugging episode here speculated that the timing of the Buback murder may be linked with efforts to bring the trial to an end.

Buback was said to be the man the defendants disliked the most and was the frequent target of courtroom attacks by both defendants and their lawyers, who said Buback was connected with foreign secret service agencies.

Though no specific proof of any connection between the assassins and the jailed Baader-Meinhof defendants was made today, the West German news agency DPA said it received a call from the "Ulrike Meinhof Special Action Group" taking responsibility for the killing.

Ulrike Meinhof was the alleged philosophical leader of the gang. She committed suicde a year ago, hanging herself in her cell.

Buback is the second high-ranking justice official to be murdered here in recent years.

Berlin Judge Guenther von Drenkmann was killed in November, 1974, by assassins who said it was to revenge the death in jail the previous day of Holger Meins, one of the five original Baader-Meinhof defendants.

Meins died of a hunger strike in protest over the conditions in which the prisoners were being held, including three years of pretrial detention.

The Baader-Meinhof group was the best known of the anarchist gangs that brought urban violence to a number of West German cities in the early 197s.

In recent years, police have made numerous arrests that, they thought, had broken the back of the big, ideological gangs like Baader-Meinhof and their successors, the "June 2d Movement."

Nevertheless, sporadic bombings and events like today's killing have made it clear that there are, as Buback said, many terrorists still at large.