Mehmet Ali Agca, the Turkish gunman who shot Pope John Paul II in May 1981, said today that the attempted assassination had been commissioned by a Soviet diplomat in Bulgaria for a sum of more than $1 million.

Today's testimony before an Italian court marked the most specific charge yet leveled by Agca against the Soviet Union in connection with the papal plot. It is the first time that the Turk has accused a Soviet official of putting up the money to murder the Polish-born pontiff.

Testifying in the trial of his alleged accomplices in the papal conspiracy, Agca also accused three Bulgarian ex-officials in Rome of providing logistical support to him and other members of a right-wing Turkish terrorist group, the Gray Wolves, in the months leading up to the assassination attempt.

Agca's testimony was in dramatic contrast with his refusal last Friday to give evidence against the accused Bulgarians. He claimed then that he was unable to testify because he had received death threats in his prison cell from the Soviet and Bulgarian secret services.

Under interrogation by the judge, Agca contradicted numerous points of his pre-trial testimony, made several errors on details and again admitted that he had lied during the course of the three-year investigation into the papal conspiracy.

The Turk's latest change of course came after a private meeting in his prison cell yesterday with his defense lawyer, Pietro D'Ovidio. Agca told the court last week that he wanted to consult his lawyer before deciding whether to continue testifying.

Public prosecutor Antonio Marini later told journalists that Agca's new charges against the Soviet Union would have to be checked by the court. The defense lawyer for the Bulgarians, Giuseppe Consolo, said that the pope's assailant had decided to implicate the Kremlin because he could not make his charges against Bulgaria stick.

Agca's claim that the Soviet Union was directly involved in the attempted murder of the pope came at the beginning of today's session when he was asked by Judge Severino Santiapichi whether he intended to continue to give evidence. He replied that he did.

Almost shouting, the 27-year-old Turk then said: "The orders to kill the pope came from the Soviet Embassy in Sofia. We Gray Wolves acted with the complicity of three Bulgarian officials in Rome . . . . The first secretary of the Soviet Embassy in Sofia paid 3 million marks" -- the equivalent in West German currency of $1.2 million at the rate of exchange then in effect.

In later testimony, Agca said the Soviet diplomat had given his name as "Malenkov" or "Milenkov." He described him as being 5 feet 11, with a "long and full" face, blond hair and glasses with a "sporting appearance."

"I ask the court to show me photos of all the members of the Soviet Embassy in Sofia. That way, you will see whether I am telling the truth or not. I will certainly recognize him," said Agca.

The judge replied that he would consider the offer. Agca identified the three Bulgarians who are on trial as his accomplices in a similar manner in November 1982, after first describing them to the Italian investigating magistrate and then being shown a photo album of 56 Bulgarian officials in Rome.

At one point in pretrial testimony, Agca accused a Soviet military attache in Tehran of involvement in the papal plot. But he later withdrew this statement, saying that he had invented the episode because he wanted to convince western public opinion that the assassination attempt was carried out on behalf of the Soviet Union.

Court records show that in January 1984 Agca also acknowledged inventing a nonexistent Bulgarian secret agent called "Malenkov" -- the name now given the Soviet diplomat in Sofia -- who, he said, had introduced him to the Soviet attache in Tehran.

Contradicting earlier testimony, Agca today said that the idea to kill the pope originally had been raised at a meeting in Istanbul in June 1980 between him and Abuzer Ugurlu, a Turkish smuggler with links to the Bulgarian authorities. He said that Ugurlu arranged for him to discuss the project in more detail in Sofia with a business partner named Bekir Celenk.

Celenk, who is now in Bulgaria, is one of the defendants. Ugurlu was arrested by the Turkish martial-law authorities several months before the attempted asassination of the pope and is now on trial in Turkey on charges including smuggling.

Agca told the court that the Soviet diplomat in Sofia used Celenk as an intermediary to pay the purported 3 million marks to Musa Serdar Celebi, head of the Gray Wolves in West Germany. No trace of this money is known to have been found.

Questioned about his meetings in Sofia, Agca said he discussed the plot to kill the pope with Celenk and one of the Bulgarian defendents, Todor S. Aivazov, between July 10 and 16, 1980. He added that another Turkish Gray Wolf, Oral Celik, also was present.

Insisting that both Aivazov and Celenk were in Sofia during this period, Agca added: "I have not invented this. These are all facts which happened. Certainly when I speak I don't expect to be believed immediately. The facts must be examined meticulously. I always tell the truth."

According to the records of the pretrail investigation, Celenk was in Sofia between these dates. Aivazov's passport, however, shows that he only arrived in Bulgaria on July 21 from Rome.

In today's testimony, Agca said that he had met Aivazov, the former cashier of the Bulgarian Embassy in Rome, under the code name "Petrov." In his pretrial testimony, he had insisted that Aivazov's code name was "Kolev" -- and that another Bulgarian official also on trial was "Petrov."

When the judge expressed surprise at the willingness of a Soviet diplomat to meet with a well-known Turkish terrorist who had only recently escaped from prison, Agca replied that the meeting had taken place in a hotel room in Sofia without any photographers present.

"There was no proof, nothing. He didn't even tell me his real name. He just said he was Milenkov, first secretary of the Soviet Embassy," Agca said.

Agca was questioned closely on apparent discrepancies over the payment of the marks. During his pretrial testimony, Agca said that he was to have received a third of the total sum, but today he insisted that he had not been interested in money.