Just what the man who shot Pope John Paul II was doing in the capital of the Socialist Republic of Bulgaria during the hot summer of 1980 has become a subject of enormous controversy, casting a shadow over the future of East-West relations.

Mehmet Ali Agca has told Italian magistrates that he stayed in Sofia for 40 to 50 days under the protection of powerful members of an international smuggling ring known as the "Turkish mafia." The mafia, he has claimed, put him in touch with agents of the Bulgarian secret service, who in turn instructed him to murder the Polish-born pontiff.

Bulgarian spokesmen have denied having any knowledge of what Agca was up to in Sofia. While conceding that the pope's would-be assassin may have spent some time in Bulgaria after his escape from Turkey, they maintain that it was impossible to distinguish him from the millions of other Turks who pass through the country every year on their way to and from Western Europe.

The fact that Agca was in Sofia has been confirmed independently by a Turkish businessman, Omer Mersan, who has acknowledged that he had a meeting with Agca at the luxury Vitosha Hotel. With the exception of this encounter, which took place in mid-July 1980, practically everything else about Agca's stay in a country that prides itself on being the Soviet Union's most loyal ally in Eastern Europe is still a matter of dispute.

The Bulgarian episode is important because it is here, more clearly than anywhere else, that at least two competing images of Agca's career and personality can be seen to separate.

* One image is of Agca as a cynical professional assassin who was recruited as a hit man by an unscrupulous gang of international smugglers working hand in glove with the Bulgarian authorities. For the next 10 months, he traveled around Europe on a lavish expense account, waiting for the final go-ahead to kill the pope. Logistical backing in Italy was provided by Bulgarian secret agents posing as diplomats.

This version, resting largely on Agca's own testimony, has been accepted as essentially accurate by the Italian state prosecutor. The motive for killing the pope was the suppression of political upheavals in Poland through the removal of the religious-based inspiration for the Solidarity trade union movement.

* The rival image of Agca is as a 23-year-old psychopathic killer yearning for fame and recognition -- a goal that he could achieve only through political terrorism. The right-wing assassination squad to which he belonged was forced out of Turkey in the course of 1980. Its attack on the pope was motivated by antiwestern Islamic fundamentalism and a vague desire to promote anarchy in Europe.

Support for this version has come from one of Agca's former associates, Yalcin Ozbey, who has blamed the attempted assassination of the pope on the same "well-organized group" that had carried out the 1979 murder of the liberal newspaper editor, Abdi Ipekci, in Istanbul. In a recent interview with West German television, Ozbey said both crimes were part of "an extensive political plan" drawn up by a group of youths from Malatya in eastern Turkey. He depicted Agca as a convinced "anticommunist."

According to other theories, Agca and his friends may have sought help on their own from outside organizations such as the Bulgarian secret service or the Italian and Turkish mafias. Some researchers have drawn attention to the fact that, at the time of the attack on the pope, the Vatican was in the throes of an internal crisis triggered by the impending collapse of Italy's leading Catholic bank.

Flaws can be found in all these scenarios -- not the least because few of the people involved are fully credible witnesses. But it is worth keeping them in mind as we follow Agca's footsteps from Bulgaria to St. Peter's Square. They represent different elements in a kaleidoscope of possibilities. Adventures in Sofia

The Hotel Vitosha, the center of Agca's adventures in Sofia, no longer lives up to the reputation for vice and high living that it has gained in the West. The prostitutes have been cleared out of the lobby, the cavernous nightclub has ceased to be a hangout for illegal money-changers, and the food in the hotel's three restaurants is depressingly mediocre.

The gloomy atmosphere extends to the gambling casino on the 30th floor, where assorted foreign businessmen with nothing better to do fritter away wads of $100 bills at the roulette and blackjack tables.

Bulgaria moved to clean up its act soon after it became the focus of international attention in November 1982, when news of Agca's allegations first broke. Visa regulations for visiting foreign tourists were tightened. Hundreds of smugglers, including influential members of the "Turkish mafia" who had been using Sofia as a base, were expelled discreetly. The state-controlled news media suddenly began announcing a series of drug busts at the frontier.

In the summer of 1980, however, it still would have been comparatively easy for Agca to enter Bulgaria unnoticed. All he had to do to be allowed into the country was to present his false Indian passport (made out in the name of "Yoginder Singh") at the border and pay a $10 "tourist fee." .

This seems to have been more or less what happened. In his report, Italian prosecutor Antonio Albano wrote that Agca entered Bulgarian territory "without particular inspections and formalities."

A low-ranking Turkish official at the customs post of Kapikule was arrested last month on charges of having helped Agca leave Turkey and cross into Bulgaria. Turkish newspapers reported that the incident, which matches Agca's own testimony in Rome, came to light during an investigation into a smuggling and corruption scandal at the border.

Once in Sofia, Agca seems to have joined the demiworld of foreign "students," petty crooks and smugglers whose presence is tolerated, even encouraged, throughout Eastern Europe because it represents a valued source of western currency. He told Italian magistrates that he stayed in the Bulgarian capital under the protection of Abuzer Ugurlu and Bekir Celenk, whom he depicted as the "godfathers" of the Turkish mafia.

Ugurlu, 37, was a well-known figure in Sofia at the time. He had been convicted in 1974 of smuggling 27 million cartridges and 70,000 guns into Turkey via Bulgaria, but had been released in a subsequent amnesty. He was also wanted by Interpol for the smuggling of large quantities of cannabis between Syria and Western Europe. He surrendered to the Turkish military authorities in March 1981 -- two months before the attempted assassination of the pope -- and is now in prison in Turkey.

Celenk, 45, a Turkish businessman with offices in London and Munich, is wanted in both Turkey and Italy on smuggling charges. For the past year and a half, he has been living in Bulgaria under police supervision.

The Bulgarian government has denied having had anything to do with the gigantic smuggling operation conducted by the Turkish mafia -- but it seems inconceivable that the "godfathers" could have operated through Sofia for so long without official approval. Associates of Ugurlu have stated publicly that they paid regular commissions to the Bulgarian authorities in return for being allowed to conduct their activities free from harassment.

Evidence of Bulgaria's involvement in arms, cigarette and narcotics smuggling from the late 1960s onward was published in a report this year by the U.S. Drug Enforcement Administration. It is supported by the independent research of Turkish investigative journalists such as Ugur Mumcu, a columnist for the daily newspaper Cumhurriyet, who has alleged that huge quantities of arms were smuggled to Turkish terrorists of both left and right through Bulgaria in the period leading up to the September 1980 Turkish military coup.

"Bulgaria is a land bridge between Turkey and Western Europe. The arms trade was a kind of business for the Bulgarians, which also gave them a certain political influence over the countries in the region. But their primary interest was in making money. They did not make a distinction between left and right," Mumcu said in an interview in Ankara. Marks for "Metin"

Omer Mersan, 30, who has acknowledged meeting Agca in Sofia, is an employe of a Turkish import-export company based in Munich. Described by the Italian prosecutor as "a swindler well-placed with the Bulgarian authorities," he worked closely with the Ugurlu family.

According to testimony given by Mersan to Italian magistrates, Agca introduced himself as a student from Turkey named "Metin" and explained that he had been sent to see him in Sofia by Ugurlu. He then asked for 2,000 West German marks (about $800 at the current exchange rate).

In order to check Agca's story, Mersan phoned Ugurlu, who was then in Istanbul. Ugurlu instructed him to pay "Metin" the sum he wanted.

This incident has since assumed considerable importance, as it appears to support Agca's claim that he received financial assistance from the "godfather" of the Turkish mafia. Ugurlu, who is now on trial in Turkey on charges of complicity in the 1979 murder of the liberal newspaper editor Abdi Ipekci, has insisted that he never even met Agca.

Ugurlu's version of what happened is that he authorized payment of the 2,000 marks to someone he knew only as "Metin" as a favor to another member of the rightist Gray Wolves organization named Dogan Yildirim. This account is at least partially supported by the report of the Turkish military prosecutor investigating the Ipekci case, which states that Yildirim did ask Ugurlu to help "Metin" out.

Yildirim, a one-time customs official, knew both Agca and Ugurlu. While serving a prison sentence in Istanbul's Kartal-Maltepe prison in 1979 at the same time as Agca, he was visited by Ugurlu. Ugurlu has acknowledged visiting Yildirim, along with some other rightist detainees, in the prison.

The truth about Ugurlu's relationship with the Gray Wolves and Agca will have to await the outcome of several interlocking trials both in Turkey and in Italy. What is already clear is that, as the head of an international smuggling ring, Ugurlu enjoyed an amazing variety of contacts. Fellow smugglers have accused him of working as an agent for the Bulgarian secret service. Mumcu, the Turkish investigative journalist, believes that Ugurlu was also connected with the Turkish intelligence agency, MIT.

Agca's stay in Sofia coincided with one of those dramatic upheavals that seem to recur somewhere in the Soviet Bloc once a generation. This time the crisis was taking place in Poland, at the other end of Eastern Europe from Bulgaria, and it seemed to owe a lot to the wave of nationalistic-religious euphoria produced as a result of the election of the first Polish pope in history in 1978.

At first, it looked as if the Communist authorities would succeed in retaining their grip on Poland. The turning point came in mid-August, when workers in the Baltic port of Gdansk barricaded themselves inside the Lenin Shipyard, plastering pictures of the pope on the gate and demanding the right to legally recognized free trade unions. The world watched in amazement as the government, instead of breaking up the rebellion by force, actually opened negotiations with the strikers.

According to the Italian state prosecutor, relying on Agca's testimony, the initial planning sessions in the papal plot took place in Sofia at the end of July -- some two weeks before the shipyard strike in Gdansk and a month before the launching of the Solidarity trade union movement. The meetings are said by the prosecutor to have been attended by four people: Agca; his Gray Wolves associate Oral Celik; Bekir Celenk of the Turkish mafia; and "Sotir Kolev," a Bulgarian secret agent later identified by Agca as Todor S. Aivazov, the administrative officer of the Bulgarian Embassy in Rome.

These four people, the prosecutor writes, "laid the conceptual, organizational and contractual foundations" for the assassination of the pope -- a task that was to be carried out in Rome the following spring.

Interviewed separately by The Washington Post by arrangement with the Bulgarian Foreign Ministry, both Celenk and Aivazov insisted that they had never met either Agca or Celik and did not even know each other. They acknowledged, however, that they had spent some time in Sofia in the summmer of 1980.

Asserting that Agca must have been "fed" information while in prison in Italy, Aivazov said: "Perhaps the fact that I was in Bulgaria on home leave at this time is the reason why I was assigned this particular role in the plot. Since I don't know Agca and haven't shown him my passport, I can only assume that he must have learned these details from somebody connected with the Italian authorities who knew perfectly well when I was out of the country."

In an interview in Rome, prosecutor Albano said there was no evidence to support Aivazov's claim, which he described as totally unfounded.

Celenk's passport shows that he was in Sofia in the middle and end of July. He told the Post that on the second occasion -- the period when he allegedly met Agca -- most of his time was taken up with negotiations for the purchase of a Bulgarian ship. Agca Heads West

At the end of August Agca turned up at the Bulgarian-Turkish frontier when, according to prosecutor Albano, he had "to surmount certain difficulties with the Bulgarian police" while crossing into Turkey. In the Turkish border village of Kapikule, the prosecutor wrote, Agca again met Oral Celik, who handed him a false passport made out to "Faruk Ozgun." A subsequent investigation showed that the passport had been issued in the Turkish town of Nevsehir, which was under the control of the Gray Wolves.

On Aug. 31, 1980 -- the day the Gdansk agreement permitting the Solidarity trade union was signed between government officials and workers in Poland -- Agca crossed Bulgaria in a Turkish tour bus. His "Faruk Ozgun" passport shows that he entered at Kapitan Andreevo and exited at Kalotina, on the border with Yugoslavia, the same day.

Just as Agca was beginning his Western European phase, the door slammed shut behind him in Turkey with the military coup d'etat. On Sept. 12, 1980, after months of rising tension, the Turkish Army generals announced that they were setting up a military "government of national salvation" to save the country from sliding into civil war.

The first consequence of the Army takeover was a series of draconian measures against terrorism of both left and right. Thousands of suspected Gray Wolves were rounded up and interned. Many were later condemned to death by military courts. But a considerable number, including many of Agca's own friends from Malatya, managed to escape.

What happened in effect was that the terrorist organization of which Agca had been a member in Turkey was uprooted and transferred to Western Europe.

According to both his Italian and Turkish interrogators, Agca has long prevaricated about the precise roles played by his immediate accomplices. It is interesting, however, to note how many of his Turkish Gray Wolves associates he bumped into during his travels in Western Europe. They include Abdullah Catli, Mehmet Sener, Yalcin Ozbey and, first and foremost, Oral Celik.

Celik, who was described by the Italian prosecutor as being "dearer to Agca than a brother," is said to have accompanied his protege in Switzerland, Austria and Italy. He is also alleged to have arranged for the purchase from a Viennese gun dealer of the Browning 9-mm pistol that Agca was later to use in his attack on the pope.

For the next eight months, Agca crisscrossed Europe, staying either with acquaintances from his Gray Wolf days in Turkey or in modest hotels and boarding houses. Wanted in Turkey for the murder of newspaper editor Ipekci, he seems to have spent much of his time in Switzerland and Austria. But sightings were also reported in Italy, West Germany and France.

Agca later confided to Italian magistrates that, wherever he went on his travels, he always took care to jot down the names and telephone numbers of people he met. It was always possible that they could come in handy one day, he explained. A Meeting in Milan

The leader of the Turkish rightists in Western Europe at this time was a former customs official named Musa Cerdar Celibi. Based in the West German city of Frankfurt since December 1978, Celibi, 28, ran the Federation of Turkish Idealists Abroad -- ostensibly a cultural organization for Turkish workers, but in practice the foreign offshoot of the Gray Wolves.

According to a telex from Interpol cited in the Italian prosecutor's report, Agca first attempted to get in touch with Celibi's organization in a telephone call from Sofia in July 1980. He phoned Celibi from Zurich in September and eventually met him in person in the northern Italian city of Milan in December.

Agca has told Italian magistrates that, at the Milan meeting, he outlined to Celibi "the hypothetical possibilities" of various terrorist acts including one against the pope. He also has claimed that Celibi attended a meeting at the Sheraton Hotel in Zurich in March 1981 at which Bekir Celenk outlined final plans for the papal assassination and the payment of 3 million German marks (then about $1.2 million) on behalf of the Bulgarian secret service.

According to Agca, this sum was to be split three ways between himself, his friend Celik and Celibi.

Celibi has now acknowledged to Italian magistrates that he did meet Agca in Milan in December or November 1980 and in Zurich in March 1981. But he has denied any involvement in the papal plot. His version of the story is that he knew Agca as "Murat" -- a Turkish student who was constantly pestering his federation for money. The most he will concede is that he paid "Murat" 800 marks ($300) during their meeting in Milan.

The circumstantial evidence cited in the Italian prosecutor's report for links between Celibi and Agca is strong. The prosecutor appears to have had much more difficulty, however, in his attempts to establish that Celenk acted as a middleman between Celibi and the Bulgarians.

The prosecutor wrote that Agca and Celik "considered Celibi and his organization as an indispensable supporting network for funds and security in their terrorist activities."

Celibi's federation also helped Agca hide the pistol he would later use to shoot the pope. A member of the federation living in Olten, Switzerland, Omer Bagci, 27, has now confessed to keeping the pistol for Agca and delivering it to him on request at the Milan railway station on May 9, 1981 -- four days before the assassination attempt.

The care which Agca took to store this weapon in Switzerland jars somewhat with his assertion that, on the day of the shooting, his accomplice Oral Celik was simply handed an attache case containing two panic bombs and two pistols by Bulgarian secret agents on the way to St. Peter's Square.

It is almost as if there are two parallel plots that have somehow become merged into one. The first, laboriously uncovered by investigators in several countries, involves Agca and his right-wing Gray Wolves associates going to considerable lengths to cover their tracks. The second, volunteered by Agca himself, centers on a Keystone Kops team of Communist agents operating in what would appear to be a recklessly open manner. Embassy Code Names

After he moved to Italy at the end of October 1980, Agca has told Italian investigators, he got in touch with his co-conspirators at the Bulgarian Embassy over open telephone lines.

Bulgaria's former assistant military attache in Rome, Maj. (now Lt. Col.) Zhelyo K. Vasilev, attempted to laugh off the suggestion that Agca could have set up an appointment with him in November 1980 by calling the embassy and asking to speak to "Sotir Petrov."

"If Agca had got in touch with me in this way, as he claims, the entire embassy would have had to have known my secret code name. With the exception of the ambassador, everybody in the embassy takes turns in manning the switchboard," he said in an interview in Sofia.

Soon after this initial meeting, Agca told the Italian magistrates, he was dispatched by Vasilev -- alias "Petrov" -- to Tunisia on a reconnaissance mission to explore the possibility of assassinating Tunisian President Habib Bourguiba and Maltese Prime Minister Dom Mintoff. Agca gave no motive for this assignment.

Back in Italy in December and January, Agca claimed, he held a series of meetings with the Bulgarians in Rome bars and an apartment belonging to the embassy's administrative officer, Todor Aivazov, alias "Sotir Kolev." At these sessions, plans were discussed for an attempt on the life of visiting Polish Solidarity leader Lech Walesa -- if possible, in conjunction with an attack on the pope.

After apparently spending the better part of February and March in Switzerland, Agca returned to Italy in April to enroll in an Italian language course at the University of Perugia. He did so under the assumed name of "Faruk Ozgun" but never attended any courses.

Agca spent the two weeks beginning April 25 in the Spanish holiday resort of Palma de Mallorca on a package tour costing 500,600 lire (about $350) with a planeload of Italian tourists. On May 9, he was back in Milan to pick up the gun from Bagci. A Crumpled Note

According to Agca's testimony, the three days leading up to the assassination attempt were taken up with meetings with the three Bulgarian agents and a couple of dress rehearsals in St. Peter's Square. He has said that some of these sessions took place in public bars and restaurants and that others occurred in the apartments of the Bulgarians.

Without independent witnesses to these alleged meetings, the state's case against the Bulgarians is based on Agca's own testimony and the fact that he was able to provide a number of accurate details about their movements, facial characteristics and personal habits.

Despite what he has said was an escape plan organized by the Bulgarians, Agca was captured seconds after firing two shots at the pope with his Browning semiautomatic pistol. He was grabbed by a nun, Sister Letizia, who kept yelling, "It was you, it was you," and then by Italian police.

In his pocket was less than $200 in Swiss francs and Italian lire, the "Faruk Ozgun" passport and a crumpled note in Turkish that appeared to be a list of last-minute instructions. The note included the phrase: "Be careful not to be seen around Vatican or places which might attract attention."

These were the three meager clues at the start of an investigation that would last over three years.

NEXT: Agca accuses Bulgaria