The District will soon become one of the first major U.S. cities to purge its pension fund of investments in companies operating in South Africa, and it will have done so without any apparent loss in the value of the fund, according to city officials.

Over the past two years, the city's pension managers have sold more than $42 million in such holdings, including blue-chip companies such as Ford Motor Co. and International Business Machines Corp., and replaced them with stock in other firms, usually smaller and less well-known, that do not operate in South Africa.

Yet the city's stock portfolio enjoyed a robust 31.8 percent growth in 1985 and is being touted by some city officials as a rebuke to critics who contend South Africa divestiture would threaten the health of public pension funds.

"The lesson from Washington, D.C., is that it can be done," said City Council member John Ray, who sponsored the divestment measure, which became law in March 1984. "It shows that you can implement divestiture . . .and you can continue to make money. . . . I think we've helped to pave the way."

The figures are being watched particularly closely now because in three weeks the city's fund will join only a handful of funds that actually have completed the process of divestiture, making it a real-life laboratory to test the track record of "South Africa-free" investing.

When the District law was enacted two years ago, many critics -- including some members of Congress -- argued it would tie the hands of the D.C. Retirement Board so tightly that they would be unable to make a proper return on the city's pension investments. Board officials are cautious, but contend that, to date, results have proved otherwise.

According to figures released last week, the stock portion of the retirement board's portfolio increased from $260.1 million to $361.6 million last year, including $20.9 million in new contributions from retirees and $80.6 million in growth from investments.

This 31.79 percent investment growth rate exceeds the 30.92 percent increase in the New York Stock Exchange composite index and is almost identical to the 31.84 percent growth of the Standard and Poor's 500 index, which includes virtually all of the major U.S. firms operating in South Africa. Critics Remain Skeptical

Critics, and even some of the city's financial advisers, acknowledge, however, that the District's experience has been too short and too inconclusive to make sweeping claims. They note that the stock market was extraordinarily bullish last year, making it easier for the city to pick out well-performing alternative stocks.

More significantly, the performance of the pension fund, as with any investment or mutual fund, can only be adequately assessed over the long term, ranging from five to 10 years, they say.

"This doesn't show anything," said Jack Albertine, president of the American Business Conference and an outspoken critic of South African divestiture proposals. "Everybody did well in the stock market last year. . . . But obviously, when you have divestiture, you preclude some very good market investments. . . . You have to compare D.C. over a 10-year average."

Michael J. O'Leary Jr., vice president of Callan Associates and the city's chief financial consultant, said the city's performance shows it is "possible to live with divestiture," but agreed that no definitive conclusions can yet be drawn.

O'Leary said that "it's still early to say that it proves that" divestiture has no costs. But he told a meeting of the board's investment committee last week, "One year -- so far, so good."

Ever since the early 1970s, antiapartheid advocates have been pressing local governments, universities and other public funds to divest their portfolios as a protest against South Africa's system of legalized segregation. But most public and private pension fund managers have resisted, saying that the restrictions would violate their fiduciary responsibility to protect the assets of their portfolios.

Still, 16 states, 57 cities and counties, and 63 colleges and universities have agreed to some form of divestiture so far, according to figures compiled by the American Committee on Africa.

These laws differ, and few have been as broad as the District's. Many simply limit divestiture to companies that refuse to sign the Sullivan Principles -- a voluntary code, signed by virtually all large U.S. firms, that pledges them not to discriminate against their black workers in South Africa. Divestiture Shows Mixed Results

Only a handful of local governments -- Philadelphia, Boston, and the state of Massachusetts -- actually have put full divestiture to the test, and the results have been widely debated. In Massachusetts, for example, where the legislature imposed complete divestiture in 1983, the state treasurer initially claimed it had cost the state $11 million in investment income, only to have the results sharply disputed by state lawmakers.

Now that results are beginning to come in, the impact of the District's law is likely to wind up the subject of similar debate. But what is clear is that the law -- coinciding with the appointment of new members and staff at the retirement board -- has had a dramatic impact on the structure of a portfolio that will have to provide for the pensions of about 21,000 retired and current D.C. police officers, firefighters, teachers and judges. (All other city employes are covered by the federal civil service retirement system.)

When divestiture took effect in March 1984, over the opposition of the then-chairman of the retirement board, the board controlled about $454 million in assets, including about $44.3 million in the stocks of 30 U.S. companies operating in South Africa. Among them were such blue-chips as Ford, Citicorp., IBM, Texaco Inc., Xerox Corp., American Cyanamid Co., Revlon Inc., G. D. Searle & Co. and others.

Today, thanks to asset growth, dividends and interest, and contributions from city employes, the fund is worth $683.8 million, while only six stocks worth less than $2 million still are held in companies operating in South Africa. Earl Johnson Jr., the board's executive director, said the board will easily be able to sell these within the next few weeks and be "in full compliance" by the March 8 legal deadline.

By being forced to move its investments out of the big companies that operate in South Africa and into smaller firms, the city's portfolio became more volatile and risky, city pension fund managers say. But to offset this risk, the city has deliberately pursued a more conservative investment strategy that didn't take effect until the end of 1984, making the 1985 results the first true "test" of the city's experience with divestiture, according to board officials.

Under this strategy, the board targeted 40 percent of its portfolio for safe (non-South Africa) corporate bonds and 10 percent for even safer, short-term financial instruments, such as Treasury notes and bank certificates of deposit.

The performance of outside investment funds, which manage the board's portfolio on a day-to-day basis, were reevaluated and some were replaced. In addition, a large share of the stock portfolio was farmed out to so-called passive managers whose sole charge was to invest in a representative sampling of stocks that would simply duplicate, rather than outperform, the market as a whole.

One of those managers is Wayne Wagner, of Wilshire Associates, a Los Angeles-based investment firm that manages about $42 million in city pension funds.

Wagner says divestiture has been a "constraint, but not a confinement."

O'Leary said that, overall, the city's portfolio has been "very competitive" with nondivested funds. In particular, he points to an analysis by his firm showing that the city's stock-investment performance ranks it in the upper half of 500 investment managers sampled during the city's last fiscal year.

In fact, board figures show that it has performed even better under its new management with divestiture than the old board performed without restrictions. But that is not to say that, as with anybody who plays the stock market, the board hasn't taken its lumps.

During one three-month period in 1985, for example, the city's equity portfolio actually underperformed the market: Between July 1 and Sept. 30, when the Standard & Poor's 500 index dropped 4.1 percent, the city's pension fund registered a 5.9 percent loss.

But city pension fund managers say such month-to-month fluctuations are both inevitable and insignificant. More important, they say, are signs that divestiture will become even easier in the future. More than 15 U.S. companies have pulled out of South Africa over the past two years, citing such reasons as declining sales, the increased threat of violence, and in a few cases, the social evil of apartheid. As a result, some companies that were at first prohibited to the District -- Motorola Inc., Martin Marietta and Phibro-Salomon among them -- now are permissible.