Officials at the maximum security prison near Stuttgart where West Germany's most dangerous terrorists are held faced further embarrassment today when explosives were discovered in a room to which prisoners have access.

The prison is the one where three former leaders of the Baader-Meinhof urban gerrilla gang were found dead this week, two of them shot through the head with pistols and the other hanging from a window frame by a phonography cable.

Official autopsies, witnessed by international specialists, have confirmed the deaths as suicides. Extremist sympathizers of the dead inmates have persisted in calling their deaths murder.

Government officials say they are convinced the guns were smuggled in, probably by lawyers, but how that could have happened in a fortress-like prion with many security features specially designed to check the Baader-Meinhof inmates has still not been explained.

The Justice Ministry ordered an immediate investigation oafter the bodies of Andreas Baader, Gudrun Ensslin and Jan-Carl Raspe were discovered. So far, the state justice minister and the prison director have resigned.

The explosives - about nine ounces wrapped in a plastic bag - were found behind floor molding in a cell formerly occupied by urban guerrilla Helmut Pohl. The room is now used as a storeroom for books and other belongings for other terrorist inmates.

Yesterday, investigators discovered a crude but workable communications system concealed behind cell walls and the day before other secret cavities large enough to hold a gun were turned up in Raspe's cell along with a small radio that also was supposedly not allowed.

A spokesman for the ruling Social Democratic Party, Lothar Schwarz, said tonight that recent recent revelations of what had been going on inside Stammheim jail were getting more and more like a fairy story.

The three priosn deaths were cited in a letter sent to the French leftist newspaper Liberation by West German "Red Army Faction" terrorists who kidnapped and then murdered industrilist Hanns-Martin schleyer.

In that letter, the terrorists said "we will never forget the responsibility of (West German Chancellor HelmutSchmidt and the imperialists supporting him for the blood that has been spilt."

Chief Bonn spokesman Klau Boelling said today that Bonn regarded this as "a concrete threat" against the chancellor "which we have to take very seriously." There were no immediate indications, however, if security, already tight around top government officials, has been further increased.

Wire services reported the following developments:

A government spokeman disclosed today that Ensslin, one of the imprisoned terrorists, told prison chaplains a day before her death that No other explanation was given. No other explaination was given.

The West German government announced that a state funeral for Schleyer would be held next Tuesday in Stuttgart, his hometown.

A bomb believed planted by a terrorist exploded today at a courthouse in Hannover without causing any injuiries.