The full story of the turnabout by the I.R.S. has remained hidden behind taxpayer privacy laws for nearly four years. But an examination by The New York Times found that the exemption followed a series of unusual internal I.R.S. actions that came after an extraordinary campaign orchestrated by Scientology against the agency and people who work there. Among the findings of the review by The Times, based on more than 30 interviews and thousands of pages of public and internal church records, were these:

*Scientology’s lawyers hired private investigators to dig into the private lives of I.R.S. officials and to conduct surveillance operations to uncover potential vulnerabilities, according to interviews and documents. One investigator said he had interviewed tenants in buildings owned by three I.R.S. officials, looking for housing code violations. He also said he had taken documents from an I.R.S. conference and sent them to church officials and created a phony news bureau in Washington to gather information on church critics. The church also financed an organization of I.R.S. whistle-blowers that attacked the agency publicly.

*The decision to negotiate with the church came after Fred T. Goldberg Jr., the Commissioner of the Internal Revenue Service at the time, had an unusual meeting with Mr. Miscavige in 1991. Scientology’s own version of what occurred offers a remarkable account of how the church leader walked into I.R.S. headquarters without an appointment and got in to see Mr. Goldberg, the nation’s top tax official. Mr. Miscavige offered to call a halt to Scientology’s suits against the I.R.S. in exchange for tax exemptions.

After that meeting, Mr. Goldberg created a special committee to negotiate a settlement with Scientology outside normal agency procedures. When the committee determined that all Scientology entities should be exempt from taxes, I.R.S. tax analysts were ordered to ignore the substantive issues in reviewing the decision, according to I.R.S. memorandums and court files.

The I.R.S. refused to disclose any terms of the agreement, including whether the church was required to pay back taxes, contending that it was confidential taxpayer information. The agency has maintained that position in a lengthy court fight, and in rejecting a request for access by The Times under the Freedom of Information Act. But the position is in stark contrast to the agency’s handling of some other church organizations. Both the Jimmy Swaggart Ministries and an affiliate of the Rev. Jerry Falwell were required by the I.R.S. to disclose that they had paid back taxes in settling disputes in recent years.

In interviews, senior Scientology officials and the I.R.S. denied that the church’s aggressive tactics had any effect on the agency’s decision. They said the ruling was based on a two-year inquiry and voluminous documents that showed the church was qualified for the exemptions.

Mr. Goldberg, who left as I.R.S. Commissioner in January 1992 to become an assistant secretary at the Treasury Department, said privacy laws prohibited him from discussing Scientology or his impromptu meeting with Mr. Miscavige.

The meeting was not listed on Mr. Goldberg’s appointment calendar, which was obtained by The Times through the Freedom of Information Act.

The I.R.S. reversal on Scientology was nearly as unprecedented as the long and bitter war between the organizations. Over the years, the I.R.S. had steadfastly refused exemptions to most Scientology entities, and its agents had focused numerous investigations and audits on the church.

Throughout the battle, the agency’s view was supported by the courts. Indeed, just a year before the agency reversal, the United States Claims Court had upheld the I.R.S. denial of an exemption to Scientology’s Church of Spiritual Technology, which had been created to safeguard the writings and lectures of L. Ron Hubbard, the late science fiction writer whose preachings form the church’s scripture. Among the reasons listed by the court for denying the exemption were ”the commercial character of much of Scientology,” its ”virtually incomprehensible financial procedures” and its ”scripturally based hostility to taxation.”

Small wonder that the world of tax lawyers and experts was surprised in October 1993 when the I.R.S. announced that it was issuing 30 exemption letters covering about 150 Scientology churches, missions and corporations. Among them was the Church of Spiritual Technology.

”It was a very surprising decision,” said Lawrence B. Gibbs, the I.R.S. Commissioner from 1986 to 1989 and Mr. Goldberg’s predecessor. ”When you have as much litigation over as much time, with the general uniformity of results that the service had with Scientology, it is surprising to have the ultimate decision be favorable. It was even more surprising that the service made the decision without full disclosure, in light of the prior background.”

While I.R.S. officials insisted that Scientology’s tactics had not affected the decision, some officials acknowledged that ruling against the church would have prolonged a fight that had consumed extensive Government resources and exposed officials to personal lawsuits. At one time, the church and its members had more than 50 suits pending against the I.R.S. and its officials.

”Ultimately the decision was made on a legal basis,” said a senior I.R.S. official who was involved in the case and spoke on the condition that he not be identified. ”I’m not saying Scientology wasn’t taking up a lot of resources, but the decision was made on a legal basis.”

The church’s tactics appear to violate no laws, and its officials and lawyers argued strenuously in a three-hour interview at church offices in Los Angeles last month that the exemptions had been decided solely on the merits. They said the church had been the victim of a campaign of harassment and discrimination by ”rogue agents” within the I.R.S. Once the agency agreed to review the record fairly, they said, it was inevitable that the church would be granted its exemptions. ”The facts speak for themselves,” said Monique E. Yingling, a Washington lawyer who represented the church in the tax case. ”The decision was made based on the information that the church provided in response to the inquiry by the Internal Revenue Service.”

Church officials and lawyers acknowledged that Scientology had used investigators to look into their opponents, including I.R.S. officials, but they said the practice had nothing to do with the I.R.S. decision. ”This is a church organization that has been subjected to more harassment and more attacks certainly than any religion in this century and probably any religion ever, and they have had to perhaps take unusual steps in order to survive,” Ms. Yingling said.