The weather was balmy in Orlando, Fla., when partners of the accounting firm KPMG gathered in November 2003 for their annual meeting, but hundreds were glued to television sets.

They were watching C-Span's coverage of a Senate subcommittee hearing into four questionable tax shelters created and sold by KPMG that earned the firm $124 million in fees, but cost the Treasury, according to Senate investigators, at least $1.4 billion in unpaid taxes. Confronted with KPMG e-mail messages and documents that showed tax executives aggressively pushing the shelters to clients, KPMG executives at the hearing were evasive. One irritated senator asked a KPMG senior executive to "try an honest answer."

A current senior executive said later that for the partners, "it was like watching your own house burn down."

Three weeks after the hearings, KPMG's chief executive, Eugene D. O'Kelly, called a meeting of the firm's 15-member board, and there, according to the senior executive, he announced that KPMG was taking "a new direction."

That new direction paved the way for a settlement with the Justice Department over the creation and sale of the arcane tax shelters, which the Internal Revenue Service contends helped wealthy investors illegally hide billions of dollars in taxable income. The agreement, which is expected to be announced tomorrow, calls for the firm to pay $456 million and accept an outside monitor of its operations. Former partners separately may face criminal charges.

The December 2003 board meeting was the turning point for the firm in its seven-year battle with the government. After years of fiercely resisting questions from the I.R.S. and Justice Department about its tax shelter business, KPMG was going to cooperate with the government's investigation. KPMG had realized that its defiance was threatening its existence.

KPMG was not alone in creating and marketing questionable tax shelters in the 1990's. The story of how KPMG got in the government's cross hairs and how it ultimately dodged a bullet is another illustration of how corporate dealings with regulators and investigators have changed significantly since the collapse of Enron in 2001.

Former partners and managers and current executives who were interviewed about the company's recent history were not willing to be named because they feared angering prosecutors. A government official spoke about the case on the condition that he not be named because the investigation is continuing.

The smallest of the remaining Big Four accounting firms, KPMG was a latecomer to the tax shelter business. The stock market boom had spawned scores of dot-com millionaires, many of them keen to shield their new riches from taxes. Accounting firms, seeing a more lucrative business than their traditional auditing practice, were eager to help.

As the report of the Senate subcommittee noted in 2003, "dubious tax shelter sales are no longer the province of shady, fly-by-night companies with limited resources." It had become a big business. Nearly every big and midsize accounting firm created "tax products" that usually involved complex swap transactions to create losses on paper that their individual and corporate clients could use to secretly erase taxable income.

Regulators eventually caught on to such schemes, and a number of firms, including Ernst & Young and PricewaterhouseCoopers, settled with the government early on.

Not KPMG.

"We came to the party late. We drank more, and we stayed longer," said a former member of KPMG's board.

KPMG went full-bore into creating and selling aggressive tax shelters only around 1997, after it held failed merger talks with Ernst & Young, according to a member of KPMG's board at that time.

The talks afforded KPMG the opportunity to analyze Ernst & Young's books in detail, and it was disturbed by what it saw: a major competitor growing at a rapid rate, and making lots of money, by aggressively selling tax shelters, sometimes to KPMG's own audit clients.

KPMG's chief executive at the time, Stephen G. Butler, and other senior executives decided that the firm needed to copy its competitor, the former board member said. Mr. Butler, who retired in mid-2002, did not return calls to his home in Leawood, Kan. A spokesman for KPMG, George Ledwith, declined to respond to any questions.

To ramp up the tax services business, the firm turned in 1998 to the head of its tax department, Jeffrey M. Stein, a charismatic lawyer who thrived on what an e-mail message released by the Senate subcommittee called "ruthless execution."

His acolyte, Richard Rosenthal, who later became chief financial officer, was known within the firm for sending e-mail messages in 18-point red type that said: "You will do this now."

Throughout the late 1990's, Mr. Stein held mandatory weekly conference calls with KPMG's 500 or so tax partners. A former KPMG senior manager who sat in on the calls and objected to Mr. Stein's approach said Mr. Stein would tell anyone who questioned a tax strategy that they were "either on the team or off the team."

Under Mr. Stein, Mr. Rosenthal and others, KPMG built an aggressive marketing machine to sell tax shelters it created, with names like Blips, Flip, Opis and SC2. From the late 1990's, KPMG operated a telemarketing center in Fort Wayne, Ind., that cold-called potential clients, gleaned from public lists of firms and companies.

The tax department, with more than 10,000 partners and employees, became the golden child of KPMG. By 2002, the firm was deriving nearly $1.2 billion of its $3.2 billion in total United States revenues from tax services - by far a greater percentage than any other large firm, according to a 2003 report by the Government Accountability Office.

Mr. Stein and his lawyer, C. Michael Buxton, declined to respond to questions about the firm's practices.

By 1999, KPMG, like most of its competitors, had wound up on the I.R.S.'s radar screen, as anonymous informants began telling I.R.S. auditors about the tax shelter schemes. In 2002, the agency issued dozens of summonses to KPMG asking it to turn over information about certain tax shelters and their investors.

KPMG refused, later releasing only names of some investors. The firm had come from behind to crush the competition and become a major seller of tax shelters. Now it would try to fight off any scrutiny of its tax shelter business.

"What clearly got them into trouble was their hardball approach," said the former senior manager, who cooperated with the investigation.

With a stable of former I.R.S., Treasury and Justice Department officials in its ranks, KPMG thought it could outsmart or outmaneuver the I.R.S., according to the former partner.

"KPMG viewed its conduct as above reproach, in a sense viewing itself as smarter than the I.R.S. and Department of Justice by developing these creative tax shelters," said Peter J. Henning, a professor of criminal law at Wayne State University Law School.

When Ernst & Young agreed in 2003 to settle a civil claim with the I.R.S. and pay a $15 million penalty, Mark A. Weinberger, at the time the vice chairman for tax services at that firm, said that it had two choices in dealing with the government. "We could have chosen fighting and a protracted battle, which would have impacted our clients and us," he said, "or we could have tried to resolve all the issues and get this behind us."

But when KPMG came under scrutiny, it chose to fight. And it did so after the collapses of Enron and WorldCom, at a time when the tide of corporate history was turning decisively in favor of corporate accountability and government regulators.

"It's a very high-risk strategy to start out stonewalling," said John A. Strait, a criminal law professor at the Seattle University School of Law.

For nearly a year, KPMG's then-outside lawyers, King & Spalding and later, Kronish Lieb Weiner & Hellman, filed scores of procedural documents supporting KPMG's assertion that it did not need to turn over the tax shelter documents. They were so effective at resisting the requests that by July 2002, the Justice Department had filed a civil lawsuit against the firm seeking to force it to comply with the I.R.S. summonses.

Then KPMG hit a wall. The Senate subcommittee report, brimming with internal e-mail messages and documents obtained from informants and through subpoenas, portrayed the firm's tax department as a place where questions about the legitimacy of shelters were barely considered, where the fees from such shelters were seen as outweighing the risks and where clients could be coaxed into buying them. The Senate hearing "was the beginning of the end" for KPMG, said the former senior manager.

The first major house-cleaning step came in January 2004, when KPMG announced the retirement of Mr. Stein, by then the No. 2 executive, reassigned Richard Smith, then vice chairman of tax services, and placed a third senior partner, Jeffrey Eischeid, on leave. Mr. Smith was fired earlier this year.

But the changes were not enough.

One month later, in February 2004, the Justice Department convened a grand jury in Manhattan. Despite overtures by its new lawyers, Skadden, Arps, Slate, Meagher & Flom, KPMG could not avert a criminal inquiry.

For one, KPMG was still resisting turning over important documents. In part, KPMG continued to resist because of major divisions within the firm over how to proceed, according to a government official involved with the investigation.

By May 2004, KPMG had so angered a federal judge in Washington over its continued refusal to turn over certain documents that the judge, Thomas F. Hogan, issued an opinion raising the possibility that the firm was obstructing justice.

KPMG needed more help. In March 2005, it hired Sven Erik Holmes, a former federal judge from Tulsa, Okla., as its vice chairman of legal affairs, bringing him in over Claudia L. Taft, KPMG's top inside lawyer. Mr. Holmes set about cleaning house, firing about a dozen partners and effectively taking over the firm's legal department.

Months earlier, Robert S. Bennett of Skadden, Arps had inherited what he told people was "a disaster of a case," with "the I.R.S. like bees" about KPMG. By June, he was pleading with the Justice Department not to indict the firm. He succeeded, but only after the firm made an extraordinary and unusual admission of "unlawful conduct" in the tax shelter business by former partners between 1996 and 2002.

Because of its resistance, KPMG did not have "the luxury of saying to the government, you're pushing us too far," said a person close to the firm, adding later that the agreement "is about survivability."

Jonathan D. Glater contributed reporting for this article.

This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit to those who have expressed a prior interest in receiving the included information for research and educational purposes. For more information go to: http://www.law.cornell.edu/uscode/17/107.shtml. If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner.