On Oct. 8, 1993, 10,000 cheering Scientologists thronged the Los Angeles Sports Arena to celebrate the most important milestone in the church's recent history: victory in its all-out war against the Internal Revenue Service.

For 25 years, I.R.S. agents had branded Scientology a commercial enterprise and refused to give it the tax exemption granted to churches. The refusals had been upheld in every court. But that night the crowd learned of an astonishing turnaround. The I.R.S. had granted tax exemptions to every Scientology entity in the United States.

''The war is over,'' David Miscavige, the church's leader, declared to tumultuous applause.

The landmark reversal shocked tax experts and saved the church tens of millions of dollars in taxes. More significantly, the decision was an invaluable public relations tool in Scientology's worldwide campaign for acceptance as a mainstream religion. On the basis of the I.R.S. ruling, the State Department formally criticized Germany for discriminating against Scientologists. The German Government regards the organization as a business, not a tax-exempt religion, the very position maintained for 25 years by the American Government.

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.