A massive investigation into Turkey's major far-right political party has suggested ways how a fugitive Turkish terrorist such as Mehmet Ali Agca, accused of shooting Pope John Paul II last Wednesday, could find underground refuge in Western Europe after escaping from prison here 18 months ago.

The probe has led to a 945-page criminal indictment against 587 leaders of the ultraconservative National Action Party, whose militant Gray Wolves are blamed for many murders of leftists and liberals in the factional strife that led to last September's military coup.

Submitted recently to the Turkish martial-law court by seven military prosecutors after six months of sifting seized documents and interrogating imprisoned party officials, the indictment makes no attempt to focus on Agca or explain possible motives for the alleged assassination attempt.

It implies, however, that Agca had direct ties to the feared Gray Wolves and obtained shadowy help from the National Action Party in fleeing to Iran after his November 1979 prison escape. Agca had been arrested earlier that year for the assassination of Abdi Ipekci, a leading liberal newspaper editor. He is mentioned in the indictment in connection with that slaying.

Another man sought in connection with Ipekci's killing, Mehmet Sener, has never been apprehended and today in Rome was being sought for questioning in the attempted slaying of the pope.

Agca, 23, and called extremely intelligent and dangerous by Turkish officials who questioned him after the Ipekci slaying, disappeared into the underground despite warnings by Turkish police officials to Interpol and European law enforcement agencies that he was at large in Europe.

The indictment describes the kind of world into which other Turkish terrorists are said to have disappeared, and thus should be of special interest to investigators trying to piece together Agca's success at wandering across Europe without being detected.

According to accounts now being printed almost daily in the Turkish press from detailed reading of the now-public document, the National Action Party directed 129 youth groups, called Idealists, in Western Europe, 87 of them in West Germany, where at least 1.2 million Turkish workers and political refugees live.

The indictment claims that fugitive Turkish political assassins illegally obtained West German residence permits through the Turkish Institute, which it says was established by the Bonn government, but became infiltrated by right-wing operatives.

The indictment identifies six other Idealist groups in the Netherlands, seven in Belgium, three in France, and one each in Austria and Switzerland. It alleges that the party sought to organize Turkish workers in Europe into an expatriate political force, a violation of Turkish law.

According to press reports from Europe, Agca has been traced in West Germany, Bulgaria, Cyprus, Lebanon and several other countries, and has been described as never lacking cash.

The Turkish criminal indictment deals in enormous detail with the activities of Alparslan Turkes, National Action Party chief, who along with 219 other party members faces death if convicted of attempting to seize power in Turkey by force, using the Gray Wolves as political hit squads. The party has denied all ties to the terrorist groups.

The document traces 694 political killings to the party while Turkes headed it and alleges that in the 1970s he converted party headquarters here into a terrorist operations center with an arsenal of machine guns, side arms, and explosives bought with money obtained from donations by powerful Turkish businessmen and extortion of bars, casinos, and small businesses. Police have reported seizing 20 machine guns, 333 pistols, and quantities of dynamite, bombs and explosives in raids on party offices in Ankara, Istanbul and other cities since last year's military takeover.

Turkes, 64, a retired colonel and former deputy prime minister in a precoup government, is accused of illegally paying out nearly $200,000 from secret funds traced through seized account books, and having another $200,000 in secret deposits. The payouts allegedly went to affiliates of his party, while Turkes reported only a little more than $30,000 in legal income in a recent year.

He also is accused of funneling hundreds of thousands of West German marks obtained in donations from expatriate workers through a West German bank.

The party even may have received donations from sympathizers in the United States, the indictment suggests. The document says probers found a money order of unspecified amount drawn on a San Diego bank, and sent from a man in California. The money order contained a card from "the Fascist National Party," which the probers wrote they believe is an organization called the National Fascist Party in America.

These amounts of money are vast in a country where the average annual income is $1,200 a year. The indictment traces some of it directly to Agca's flight from Turkey after slipping out of a maximum-security military prison with the help of some soldiers on Nov. 24, 1979.

The prosecutors say Agca was brought from Istanbul by car to the capital, then moved to Erzurum in northeast Turkey, about 170 miles from the Iranian border. There, the indictment says, he was sheltered by Timur Selcuk, a local Idealist member who since has told authorities he received $1,000 from an Idealist association. Selcuk related that he took Agca to a professional smuggler at a coffeehouse near the frontier and that then Agca disappeared.