Civil rights groups have financed a surprise out-of-court settlement with a white schoolteacher who was laid off by a Piscataway, N.J., school board eager to preserve the job of a black teacher. The deal, announced yesterday, was designed to forestall what the groups feared could have been a precedent-setting Supreme Court ruling limiting the use of affirmative action in the American workplace.

It is rare for any case to be settled once the Supreme Court has agreed to hear the dispute, and virtually unheard-of for third parties to direct the settlement. But the civil rights groups believed that the stakes were so high in this case that it was better to intervene than risk an adverse high-court ruling.

The Piscataway school board had vigorously fought the case for eight years, but voted late Thursday to settle with the white teacher after black civil rights groups agreed to put up about 70 percent of the $433,500 needed to pay her back salary and legal bills.

Sharon Taxman had sued alleging reverse discrimination in 1989 when, for reasons of racial diversity, she was laid off so that the school board could keep Debra Williams, the only black teacher in the business department where the two women worked. Taxman, who was later rehired, had won in lower courts.

Forcing an out-of-court resolution and paying off the white teacher was a bold and unusual move for the NAACP Legal Defense and Educational Fund and other civil rights advocates that have vigorously defended numerous affirmative action cases in the past and who had backed the school board's effort. But proponents of affirmative action thought the Piscataway case presented too great of a risk: Given the court's recent spate of decisions limiting the use of race-based policies, the groups did not want to give the justices an opening to strike down programs that benefit minorities in a range of settings, on the job and in college admissions. The legal question was whether the benefits of race could ever be grounds for excluding a white person, or if such a choice could be made only to remedy specific and documented past discrimination.

"This was a bad case for a decision on the bigger issues of affirmative action," said ACLU lawyer Christopher A. Hansen.

The facts were unique. The school board asserted that the two teachers, who had been hired on the same date in 1980, were equally qualified and that race was the single deciding factor in determining which teacher to keep in the face of budget cutbacks and declining student enrollment. But the board had made no formal findings justifying the need for diversity within the small business education department where the women taught.

Nonetheless, school board officials believed they had a strong case and initially were supported by the Clinton administration. Earlier this year, the administration reversed course. In an effort to avoid a ruling prohibiting the use of racial diversity as a basis for making employment decisions, the government told the justices they should simply uphold a lower court finding that the board acted unconstitutionally when it laid off a teacher solely because of her race and without detailed justification.

The board had acknowledged that it was not trying to remedy any past discrimination or compensate for the under-representation of minorities. Rather, it made the decision to lay off the white teacher because it wanted to expose students to a diverse faculty.

Yesterday, school board lawyer David B. Rubin said the board did not realize in 1989 that it "would become the lightening rod in a stormy national debate over affirmative action."

And although school board officials had fought in the face of two lower court rulings favoring the white teacher, civil rights groups eventually convinced them it was dangerous to move forward.

"Once the case was accepted by the court," Rubin said, civil rights groups raised a "genuine concern that an adverse ruling in this case could gut the infrastructure of affirmative action across the country."

In recent years a narrow majority on the Rehnquist Court has ruled against policies intended to compensate for past discrimination and benefit people based on their race, limiting the use of affirmative action in both municipal and federal contracting awards and in voting districts. The justices also let stand two controversial lower court decisions, outlawing Texas college admissions programs favoring blacks and Hispanics and upholding California's Proposition 209, which bans preferences based on race or sex in public hiring, contracting and school admissions.

The Piscataway dispute could have affected hiring and firing policies not just in government -- as the court's most recent race-related decisions have -- but in virtually every American workplace. If the Supreme Court had embraced the lower court reasoning, it would stop companies from making employment decisions based on race except to remedy past discrimination.

Yesterday, Taxman's lawyer, Stephen E. Klausner, said his client was pleased with the resolution. Taxman, who has declined to speak directly with reporters, will get about $186,000 to compensate for back pay and fringe benefits. "For her, this was about seniority and pension benefits," Klausner said.

Meanwhile, Williams, who was never actually a party to the lawsuit, was reportedly upset over the board's settlement. She did not return telephone calls but in an earlier interview with The Washington Post expressed concern that people in her community and outside had begun regarding her as someone who kept her job only because she was black.

"I was always taught that the most competent person gets the job," Williams said, but she added that she believes that racial diversity among faculty is important for students.

"It's important to have students meet someone they can look up to as a role model," she said in an interview last summer. "Diversity is important. They need someone they can relate to. They need to be able to say, `Debbie made it, so can I.' "

Williams said the case had divided the two teachers and their high school community.

And the case had appeared ready to divide the high court, which in recent years has been deciding cases by one vote, typically that of Justice Sandra Day O'Connor. While a five-justice majority has ruled against race-based policies, it has nonetheless left the door open to programs that are narrowly tailored to meet a compelling governmental interest -- a tough standard to meet.

The lower court decision in Piscataway Township v. Taxman had gone further. The 3rd Circuit Court of Appeals said the only justifiable "government interest" is remedying past discrimination. That ruling would be the law only in the 3rd Circuit: Pennsylvania, New Jersey, Delaware and the Virgin Islands.

It is still an open question nationwide whether racial diversity can ever be grounds for such workplace decisions. Other proponents of affirmative action had been anxious about whether the Piscataway case would undermine a 1978 Supreme Court ruling that allowed racial diversity to be a factor in college admissions.

The National School Boards Association said yesterday, "Education has such a unique standing in society that school boards should be allowed to use race as a 'plus factor' when making employment decisions."