Former FBI agent Richard W. Miller has told his lawyers that he was trying to turn two Soviet immigrants into double agents when he was suddenly investigated and arrested this month by his own bureau.

Joel Levine, a former federal prosecutor now representing Miller, said today the agent demanded $65,000 in gold and cash from Svetlana Ogorodnikova and her estranged husband and "may" have had sex with her as part of his effort to turn them into U.S. agents.

Only when he reported his activities to his superiors Sept. 27 was he interrogated, fired and then arrested, said Stanley I. Greenberg, Miller's other defense attorney.

"In hindsight," said Levine, "he could have avoided all this trouble if he had reported earlier."

Levine and Greenberg said Miller's voluntary statements to an FBI lie detector expert about his activities were not a confession of wrongdoing and he plans to plead not guilty to charges of conspiracy, espionage and receiving a bribe.

In a related development, a formal complaint filed with the U.S. Equal Employment Opportunity Commission has charged the beleaguered FBI office here with favoritism toward Mormon employes, according to sources close to the case.

The complaint filed by FBI agent Bernardo M. Perez, who has been transferred to the FBI's El Paso bureau, is the first official action known to have been taken against an alleged "Mormon mafia" in the bureau here. It charges agent-in-charge Richard T. Bretzing and other supervisors with discrimination on the basis of Perez' Hispanic background and preferential treatment toward agents sharing Bretzing's Mormon faith.

One recently retired Justice Department official familiar with the operations of the Los Angeles FBI said he considered the "Mormon mafia" charges ludicrous. "You could make the same case for an Irish-Catholic mafia in the FBI," he said. "I'll wager the ratio of Fordham graduates to Brigham Young graduates is 3 to 1."

Nonetheless, some agents blame favoritism toward members of the Church of Jesus Christ of Latter-day Saints in part for the assignment of Miller, who was a Mormon, to the sensitive counterintelligence division despite a lackluster record in other positions.

Miller, 47, who friends say was in some financial trouble because of the demands of raising a family of eight children, is the first FBI agent charged with espionage against the United States. He, Ogorodnikova, 34, and her husband, Nikolai Ogorodnikov, 51, are being held without bail here and could be sentenced to life in prison if convicted.

Levine said Miller first came in contact with Ogorodnikova in May when she phoned the FBI office here. According to acquaintances and an FBI affidavit, the slim blond woman had often bragged of her contacts with both Soviet officials and the FBI. "She has had similar types of contacts with FBI agents for several years," Levine said.

According to the FBI affidavit, Miller found Ogorodnikova sympathetic to his personal and financial problems and gave her a secret FBI manual on counterintelligence. Greenberg said Miller will argue that the manual had little value and was the "most innocuous document he could find."

FBI officials have said they discovered Miller's personal relationship with the Soviet woman in early September and began to follow them and monitor their telephone calls. Greenberg said Miller felt that he was conducting a legitimate operation and went to his superiors in late September "when he felt he needed further help and support from above." He and the Soviet couple were arrested Oct. 2.

As to classified documents found in a house where Miller lived during the week, Levine said "some were for reports he was writing, which were late, and others he was using" in his investigation.