FRANKFURT, West Germany (AP) _ A witness in the trial of confessed hijacker Mohammed Ali Hamadi testified today that a pistol used in the 1985 hijacking of a TWA jetliner may have been smuggled onto the plane inside a fish.

Petra Posiege, 31, a West German federal police investigator, also told the court that information gathered by Greek police indicated hand grenades on the plane may have been smuggled in with a bunch of fruit.

Hamadi is charged with air piracy and murder in the hijacking of TWA flight 847. Thirty-nine Americans were held hostage 17 days during the ordeal.

U.S. Navy diver Robert Stethem was shot and killed by the hijackers after the Athens-to-Rome flight was hijacked on June 14, 1985.

Hamadi, a Lebanese Shiite Moslem, has admitted taking part in the hijacking, but denies killing Stethem. He has testified that his accomplice, identified in court records as Hassan Ezzeddine, shot Stethem.

Ms. Posiege said she traveled to Athens after the hijacking to ask Greek police about their arrest of another man who officials said planned to join the two other hijackers but failed to get on the flight.

Ms. Posiege said Greek police identified the arrested man as Ali Atwa, who had been taken into custody ''because he was acting suspiciously.''

''They wouldn't give any other details on why he was arrested,'' she told the court.

Under questioning, she said, ''Ali Atwa told them (Greek investigators) the pistol was smuggled aboard the hijacked plane in a fish, and the grenades were between some fruit,'' said Ms. Posiege.

However, she said Greek police told her they did not believe Atwa's story.

''They were convinced that their airport security measures were adequate, and that the weapons were placed on board the airliner in Cairo, Egypt, from where it had arrived earlier,'' Ms. Posiege said.

During the hijacking ordeal, the plane was forced to land three times in Beirut and twice in Algiers.

Stethem was killed when the plane landed the second time in Beirut.

After Stethem was shot, the hijackers forced the airliner to return to Algiers. Ali Atwa was flown there and released in exchange for all Greek passengers and the remaining women and children on the plane, court records indicate.

Ms. Posiege identifed the Greek officials she talked with only as the heads of the anti-terror, security, and Interpol offices in Athens.

Also today, a written deposition from an American passenger aboard the hijacked plane was read into the court record.

Joseph Cucchi's description of the ordeal, including beatings of passengers and the shooting of Stethem, echoed those of dozens of other witnesses who have testified earlier at the trial, which began on July 5 in a high security courtroom in Frankfurt.

Chief Judge Heiner Mueckenberger said today the court would honor a defense request to try to obtain more detailed reports on the hijacking from international aviation organizations who may have monitored radio transmissions with the TWA airliner.

Among those to be contacted were the U.S.-based Federal Aviation Agency and the International Civil Aviation Organization in Montreal.