Lawrence G. Wallace, a Justice Department official who risked his career over a high-profile discrimination case and went on to argue more Supreme Court cases than any lawyer in the modern era, died Feb. 13 at a hospital in Rockville, Md. He was 88.

The cause was complications from surgery, said his nephew, Eric Menter.

As a deputy solicitor general under eight presidents, Mr. Wallace represented the U.S. government before the nation’s highest court, delivering oral arguments in an elegant style that he likened to his after-hours performances as a violinist. “I sometimes argue in sonata form, sometimes in theme and variations,” said Mr. Wallace, who played with local groups and in an informal ensemble featuring Condoleezza Rice, a former secretary of state.

Mr. Wallace appeared at the Supreme Court with such frequency that his oral arguments were tallied up by reporters and historians, who tracked his rise through the record books as he passed two recent giants of Supreme Court advocacy, Erwin N. Griswold and John W. Davis. By the time he retired in 2003, he had argued 157 Supreme Court cases, more than any civil servant in U.S. history and more than any lawyer in the 20th century.

His legal work addressed subjects ranging from radioactive waste and sexually explicit television programming to civil rights and patent law. But among his peers, he was best known for an episode that nearly derailed his career, when he resisted pressure from Justice Department officials in a politically charged case involving racial discrimination and the Internal Revenue Service.

“It really was a remarkable thing,” said Richard J. Lazarus, a Harvard Law professor who served as a former assistant to the solicitor general. “It was a career civil servant, based on what he viewed as the principle of which arguments had merit, which arguments had integrity, standing up to the attorney general and no less than the White House. . . . The job was his life. He risked being fired in a heartbeat.”

Mr. Wallace’s actions took the seemingly undramatic form of a footnote, a short passage he wrote in a 1982 brief filed with the Supreme Court case Bob Jones University v. United States. The case centered on whether the IRS could revoke the tax-exempt status of discriminatory private schools such as Bob Jones University, an evangelical institution in South Carolina that prohibited interracial dating and marriage.

Under normal circumstances, such a high-profile case would have been handled by the solicitor general, Rex E. Lee. But when Lee recused himself, citing previous work on tax exemptions for religious schools, the case fell to his senior deputy, Mr. Wallace, who filed a brief arguing that the IRS could revoke the exemptions.

President Ronald Reagan ultimately took the opposite position, siding with Bob Jones amid a broader break with established civil rights policies. When Mr. Wallace was asked to sign a Supreme Court brief in which the government effectively reversed itself, he included a footnote on the first page noting his disagreement with the administration’s position.

A New York Times report called Mr. Wallace’s footnote “one of the more extraordinary twists in a case that is without parallel in recent Supreme Court history.” While he declined to explain why he signed the brief even though he disagreed with its argument, colleagues said that it would have been extremely unusual for the Justice Department to file such a document without the signature of someone from the solicitor general’s office.

Griswold, a solicitor general under the Johnson and Nixon administrations, told The Washington Post in 1982 that he thought Mr. Wallace’s actions were “an attempt to preserve the credibility of the office.” Those comments were echoed by Andrew L. Frey, a fellow deputy solicitor general who is now senior counsel at the firm Mayer Brown.

Mr. Wallace, he said in an interview, “felt the obligation of the Justice Department was to defend the IRS, not to reject its position. It was not a matter of his personal view, although I’m sure his personal view agreed with the IRS. It was a matter of his sense of what the obligation of the office was.”

In 1983, the Supreme Court effectively ruled for the IRS, 8 to 1, with Chief Justice Warren E. Burger writing, “There can no longer be any doubt that racial discrimination in education violates deeply and widely accepted views of elementary justice.” The Justice Department also created a new position in the solicitor general’s office, allowing a political appointee to take the reins as the government’s chief advocate if necessary.

In an interview, Lazarus compared Mr. Wallace’s actions to those of the four career prosecutors who recently withdrew from the Roger Stone case, after officials moved to undercut their sentencing recommendations for President Trump’s longtime confidant.

“There’s a political volatility to our times,” he said, “but what Wallace did was orders of magnitude of a larger dimension: a big case for the Supreme Court” involving “the constitutionality of a federal policy against racial discrimination” and “telling the U.S. Supreme Court what the executive branch thinks of the law.”

Lawrence Gerald Wallace was born in Syracuse, N.Y., on March 25, 1931. His father was a real estate broker, his mother a homemaker.

Mr. Wallace studied at Syracuse University, receiving a bachelor’s degree in economics in 1952 and a master of public administration in 1954, when he was serving in the Air Force. Five years later, he graduated from Columbia Law School, where he was editor in chief of the law review.

After trying private practice, he clerked for Supreme Court Justice Hugo Black and served on the Duke Law faculty. He was hired to the solicitor general’s office in 1968 and promoted to deputy two years later.

Mr. Wallace, who said he honed his Supreme Court arguments over long walks, avoided the standard practice of prepping for ­cases through “moot court” sessions with stand-in justices. He didn’t want to peak too soon, he said, and for the most part, his technique seemed to work. When Justice Lewis F. Powell Jr. retired from the court in 1987, he wrote to Mr. Wallace saying that he “will miss your arguments. They rank among the very best the court hears.”

On some occasions, however, Mr. Wallace was criticized for unspooling his position too slowly. A 1997 copyright case that marked his 141st oral argument, and that was reported to have broken Davis’s modern record, was particularly fraught. Mr. Wallace said he had forgotten to include a key provision in the government’s brief, and he was pummeled with questions from the justices.

Nonetheless, he was honored later that day in a celebration led by U.S. Attorney General Janet Reno and attended by four of the justices. “I’m rather amazed that it has happened,” Mr. Wallace told The Washington Post. “The cases just add up on their own. But I’ve been privileged to touch upon some history.”

According to the Yale Biographical Dictionary of American Law, Mr. Wallace’s Supreme Court record is dwarfed only by two 19th-century advocates: Daniel Webster, who argued somewhere between 168 and 249 cases, and Walter Jones, who reportedly argued 317. A current deputy solicitor general, Edwin Kneedler, is closing in on Mr. Wallace’s modern record, having argued 143 cases, according to the Supreme Court.

Mr. Wallace, who never married, is survived by a sister.

At his 157th and final Supreme Court argument, for a case involving a Victoria’s Secret trademark dispute, Mr. Wallace was honored from the bench by Chief Justice William H. Rehnquist, who congratulated him for “many years of quality advocacy and devoted service.” He then paused, looked at Mr. Wallace and declared, “That doesn’t mean we are going to rule in your favor.”