The federal government has ended its legal war against two corporate nation-states, battles that spanned a dozen years, produced millions of pages of evidence and perhaps half a billion dollars in legal fees, and touched the core of a century-old debate over the role of big business in America.

The Justice Department's antitrust suits against International Business Machines Corp. and American Telephone & Telegraph Co. constituted an attempt by the federal government to set limits on the competitive conduct of the nation's largest firms.

Both AT&T and IBM were accused of violating antitrust laws by trampling competitors who got in their way, and in both cases the government asked the courts to break up the giants into smaller pieces.

In abandoning the nearly-13-year-old IBM case, the administration presented a victory to conservative economists and business leaders who maintained that competition breaks down a monopolist's power faster and more surely than the government can. Lawyers said the message from the IBM settlement is that the same rules of conduct apply both to a small firm and a giant one, so long as the giant's power comes from superior efficiency and performance.

The AT&T settlement, requiring what would be the largest corporate dismemberment in history, is not a government defeat, said Robert Pitofsky, a former member of the Federal Trade Commission. "If that decision opens up competition, then the Sherman Antitrust Act has served a purpose" in the case, Pitofsky said.

The AT&T outcome reestablishes the "vitality" of the 91-year-old Sherman Act, said Philip L. Verveer, former chief counsel on the government's side.

What the two cases shared was their incredible size and scope.

The IBM suit, begun within the Justice Department in 1965, was filed on Jan. 17, 1969, the last day of the Johnson administration, by Attorney General Ramsay Clark. Gasoline was less than 30 cents a gallon, space officials were preparing for the first landing on the moon and Ted Williams was about to be named manager of the Washington Senators major league baseball team.

A Homeric pretrial paper chase followed, involving 66 million documents and 2,500 depositions. Frank Cary, IBM's chairman, was questioned over a total of 45 days. In May 1975, the suit finally went to trial before U.S. District Court Judge David N. Edelstein, who postponed retirement to hear the case and sometimes wondered aloud whether he would live to see its end.

The trial lasted six years, off and on, filling 104,000 pages of testimony, as the government tried to prove that IBM had broken the law by aiming at competitors one by one. Internal IBM memos spoke of "death-level" price cutting and a counteroffensive code-named "SMASH" directed at smaller companies that wanted to tie their peripheral products to IBM computers.

IBM never has disclosed what it spent on its defense, but through most of the past 13 years a team of two dozen lawyers headed by Thomas D. Barr fought the Justice Department, keeping track of the case through a sophisticated computer retrieval system.

IBM said that all it ever did was lower prices, improve its products and compete the way firms are supposed to--the opposite of a monopolist's conduct. A monopolist has the power to keep competitors out, said Barr, IBM's lead attorney. "Competitors were coming in head over heels" to seize parts of the burgeoning computer market, he said. "Nothing was done that was wrong."

The AT&T case came close to the scale of United States v. IBM. After the suit was filed in 1974, AT&T spent a quarter of a billion dollars in a six-year, pretrial procedural battle and another $100 million during the trial last year. The government's costs came to $15 million.

Government lawyers called AT&T --the world's largest corporation--a rogue elephant that used the profits from its control over the long-distance and local telephone markets to beat down competitors that threatened to move into important new markets such as the sale of complex switching equipment. With this leverage, AT&T would dominate the future of telecommunications if given the chance, the government warned.

AT&T lead attorney George Saunders said his client was "the greatest business enterprise the world has ever produced.

"It is shocking to me that of the four industries in which this country remains competitive, the Department of Justice of the United States is attempting to destroy the competitive abilility of two of them," he told the court last year.

The Reagan administration concluded that AT&T would be more than competitive, even in several somewhat smaller pieces.

And in IBM's case, Assistant Attorney General William Baxter accepted IBM's argument that far from dominating the computer market, IBM was facing an uncertain struggle against young, innovative firms, giants such as AT&T, and determined competitors from Japan and other foreign countries.

Whatever the computer market looked like in 1965 when the government first trained its sights on IBM, it has changed vastly since then, and that became a final blow to the government's case.